Skip to content

fix(database): split punctuation-joined tokens in PostgreSQL keyword search like SQLite FTS5 - #183547

Merged
steipete merged 7 commits into
openclaw:mainfrom
lonexreb:fix/183439-postgres-keyword-tokens
Oct 27, 2026
Merged

steipete merged 7 commits into
openclaw:mainfrom
lonexreb:fix/183439-postgres-keyword-tokens

Conversation

@lonexreb

@lonexreb lonexreb commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Closes #183439

What Problem This Solves

Fixes missing PostgreSQL memory and transcript matches when a query word appears inside a date, path, filename, or slash-separated pair such as 2026-08-18, /v1/models, server.py, or input/output.

User Impact

PostgreSQL keyword search finds the words SQLite FTS5 already finds. Long transcript snippets show the matching passage and retain its punctuation. Ranking policy and canonical memory/transcript content are unchanged; Unicode normalization and engine-local scores can still differ.

Agent schema 38 reparses existing PostgreSQL text indexes once, including persisted memory search extensions. SQLite advances schema metadata only. Operators should retain the matching pre-upgrade backup for rollback; the first PostgreSQL migration includes a one-time index backfill.

Why This Change Was Made

The shared PostgreSQL search owner applies the same punctuation split to indexed text and query terms. A trigger maintains the stored vector because PostgreSQL 16 cannot replace a generated expression in place, and dropping/re-adding the column would break the sealed catalog's column positions. The migration preserves those positions and GIN indexes, while historical definitions remain available for old-store backup and restore. Snippets locate the passage in position-preserving normalized text and return the corresponding original text.

Integrated main at dc960f50ad6e; main still uses agent schema 37, so this migration remains 38. Production delta is +204/-24 lines (net +180) for version propagation, the migration, and historical backup/port compatibility. Shared test-fixture cleanup keeps the test/support delta to +460/-453 (net +7), without raising the test-line ceiling. Docs are +37/-7; metadata/tooling +2/-1.

Thanks to @lonexreb for the implementation and @etzelm for the report and independent real-index validation. Contributor commits are preserved.

Evidence

Current integration proof used a disposable local PostgreSQL 17/pgvector container, synthetic data, and the production store/search owners. No operator state or database was used.

  • Current-base red → integrated-head green: the punctuation regression failed on 364c0d4ebcd4 at 08 18: expected [] to deeply equal [{id: 'deploy'}] (8.68s Vitest, 70.49s total). On the integrated head, 21/21 tests in five files passed (45.07s Vitest, 108.04s total): the same regression, populated 37→38 migration and reopen, schema-35 memory-path upgrade through current, historical backup descriptors, and the real session-search owner returning the late punctuation-preserving snippet.
  • Current checks: targeted type-aware oxlint, oxfmt, canonical PostgreSQL generator verification, and git diff --check passed. Independent P0–P2 review: scoped-clean, no actionable findings on the complete integrated diff.

The following broader CLI, Gateway, stable-upgrade and hybrid proof was previously recorded on the unchanged implementation before this main integration; it was not rerun during this pass:

  • Red before the fix: built main CLI found server on SQLite, then returned no results after a real database port --family agent --to postgres. The regression also failed on exact initial CI base 7c4bc0162dc at 08 18: expected [] to deeply equal [{id:'deploy'}] (34.80s Vitest; 252.11s including cold setup).
  • Existing-store repair: Doctor upgraded PostgreSQL 37→38 in 123.31s. Before any search/rebuild, stored vectors already contained separate 08, 18, server, py, models, input, and output tokens. All four search-column positions were preserved. Six independent CLI searches (08 18, server, models, input output, server.py, Release) passed in 130.70s; reopen retained the schema version and catalog seal.
  • Snippet and restoration: the shipped Gateway sessions.search returned the late fix to server.py landed passage with punctuation (13.62s). A verified schema-37 archive restored in 7.52s, upgraded in 43.44s, and passed search plus an independent reopen with an unchanged admitted extension set and seal.
  • Published-stable upgrade and current port: the real npm 2026.10.8 SQLite seed upgraded agent 25→38/state 20→35 in 49.77s. Both integrity checks passed, both memory chunks remained, and two opens retained identical schema metadata and recovery-file inventories. Stable predates PostgreSQL port support; the upgraded store then passed the current CLI port to PostgreSQL (19.26s) and keyword search.
  • Live hybrid control: Ollama nomic-embed-text rebuilt 768-dimensional vectors and returned server.py with text score 0.97348 and vector score 0.63478. Final rebuild/query took 44.74s/73.52s, with the same model digest before, between, and after. An earlier attempt encountered a shared Ollama outage (connection reset/refused and transient provider-identity mismatch); no service restart, model unload, suppression, or metadata edit was used.
  • Checks: final-head full build passed (455.93s); core and focused test types, targeted lint, formatting, Kysely guardrails, PostgreSQL generator verification, and applicable baseline ratchets passed. Independent Codex branch review is clean with no actionable P0–P2 findings.
  • Tests: 14 PostgreSQL files cover 114 tests. Initially 112 passed; two unchanged DROP DATABASE cleanup statements timed out during a 243s container checkpoint. Only those cases were replayed after checkpoint completion, with unchanged limits: 2/2 passed (5.62s test file, 104.13s with setup). The nine-file unit/tooling batch passed 240/240 in 570.02s. The original PostgreSQL batch took 1300.47s, including the 20-case historical rollback matrix (497.27s).

Initial CI run 40448958449 was investigated against its exact base. Four failures have independent main repairs now included: QA ACK #185840, Google Chat authority #185972, Copilot ordering #185612, and iMessage lookup #185409. The Feishu lifecycle failure did not reproduce on the exact base (8/8); its unchanged shared-state/KV path does not use this agent PostgreSQL search migration. This is an intermittent/unresolved initial failure, not a claimed fix. Final exact-head CI is recorded below.

Limitations: this integration used PostgreSQL 17; the earlier CLI proof used 17.11; PostgreSQL 16 compatibility is supported by the DROP EXPRESSION contract and the contributor's earlier PG16 run, rather than a fresh PG16 run here. The published stable's indexing command needed bounded cleanup interruption while seeding; cold integrity checks passed before upgrade.

Fresh CLI/Gateway/live-model proof was not repeated for this integration: the production-boundary PostgreSQL regression, upgrade, reopen and snippet tests were rerun, while the broader prior-head evidence above is retained explicitly.

An earlier integrated-head CI run, 40589855961, exposed eight inherited memory fixture failures in checks-node-changed-extensions-bundle-24 / -27. All eight reproduced on unchanged main 25c300f73654. Upstream repair b954f6cef456 makes embedding-failure fixtures change their input instead of expecting unchanged chunks to be embedded again; it is included by the final main integration. The PostgreSQL production owners and migration are unchanged from the earlier successful database proof. Fresh independent P0–P2 review after this integration is clean.

After the final main integration, all 16 tests across the three affected memory suites passed (163.09s total). The eight previously failing cases are green. The earlier 21-test real-PostgreSQL proof remains applicable because the integration does not change those production owners.

Final exact-head validation: CI run 40593236753 passed on 26a81af6cb1dcfab3875a5df36ec45795080e08d: 159 jobs passed, 24 skipped, no failures or cancellations. All three PostgreSQL conformance shards, all three repaired memory-test bundles, and openclaw/ci-gate passed. ClawSweeper's review of the same head is complete with no findings or Before merge items.

@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 docs Improvements or additions to documentation gateway Gateway runtime size: M labels Oct 25, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug 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

Aligns PostgreSQL punctuation tokenization across stored indexes, queries, and snippets, with an upgrade for existing agent stores.

Example: Search for server in a PostgreSQL memory note containing server.py.

  • Before: The note is missing because PostgreSQL indexes server.py as one lexeme.
  • After: The note matches server, and transcript snippets retain the original punctuation.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused shared-owner repair with product-entry-point proof, existing-state compatibility evidence, independent validation, and successful exact-head CI.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Built CLI and Doctor results cover corrected PostgreSQL retrieval and populated-store migration; Gateway sessions.search covers the punctuation-preserving passage, and independent reporter validation corroborates real-index recovery. Stable SQLite upgrade, PostgreSQL porting, historical restore, and reopen are recorded; the relevant production implementation is unchanged across the later integrations.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: PostgreSQL memory and transcript searches miss words inside punctuation-joined text that SQLite already finds.
Reason: The report demonstrates lost retrieval results, independent validation confirms recovered matches, and the repair stays within the existing search and migration owners.

Merge readiness

✅ Ready for maintainer review

This PR repairs a concrete PostgreSQL search defect still present on current main; the reviewed head has no actionable findings and passed exact-head CI.

Priority: P2
Reviewed head: 26a81af6cb1dcfab3875a5df36ec45795080e08d

Before merge

None.

Findings

None.

Agent review details

How this fits together

Memory and transcript owners declare text indexes to the shared database engine, which maintains PostgreSQL search vectors and returns matches, scores, and bounded snippets.

flowchart LR
  A[Memory and transcripts] --> B[Shared search owner]
  C[Literal query] --> B
  B --> D[PostgreSQL text indexes]
  E[Doctor migration] --> D
  D --> F[Matches and original text snippets]
Loading

Technical review

Best possible solution:

Land the shared tokenization repair with its existing-index migration and preserved historical backup definitions.

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

The linked report supplies synthetic CLI inputs and missing results, and current-main source confirms the index/query token mismatch; this read-only review ran no target code.

Is this the best way to solve the issue?

The smallest complete repair aligns indexing, query parsing, and snippet selection in the existing search owner, then recomputes existing derived vectors through the established migration owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • PostgreSQL indexed text and literal query parsing changes intended behavior with a stated reason (bf46379: Provide native PostgreSQL search through the shared engine while preserving literal queries and engine-local ranking.)
  • Installation-local search configuration keeps the original intent (3c4be0e: Keep independent installations isolated through namespace-qualified search configuration.)
  • Historical cold archive backup descriptors keeps the original intent (d4ae3a7: Preserve ordered cold transcript chunks introduced in agent schema 37.)
  • PostgreSQL fixture lifecycle keeps the original intent (e9a3cc9: Consolidate repeated database test setup without removing distinct scenarios or assertions.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +180, Tests +7, Docs +30, Config 0, Other +1. Total +218 across 37 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 16 204 24 +180
Tests 15 460 453 +7
Docs 4 37 7 +30
Config 1 1 1 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 37 703 485 +218

Review metrics

Metric Value Why it matters
Production versus test/support delta Production +204/-24; tests/support +460/-453 Production growth implements tokenization, version propagation, migration, and historical backup compatibility; shared fixtures offset the added regression coverage.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: The defect loses concrete keyword matches for PostgreSQL-backed memory and transcripts, with limited blast radius.
  • merge-risk: 🚨 compatibility: Agent schema advances from 37 to 38 and the exported StoreSchema gains an optional version field; upgrade, reopen, restore, and historical compatibility evidence cover the transition.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (8 earlier review cycles)
  • reviewed 2026-10-25T11:31:51.002Z sha ddeb057e53e0010648eb5ef1ec2863a33b866119 :: needs real behavior proof before merge. :: [P2] Include the migration module in the trusted wrapper inventory | [P3] Describe the new trigger-maintained vector in the reference
  • reviewed 2026-10-25T11:46:29.759Z sha 16cffaca6f48a09f6830c5f7472484631ee066c6 :: needs changes before merge. :: [P2] Make the new identifier references pass the Kysely guard
  • reviewed 2026-10-25T12:07:32.968Z sha 5527c38cd21e58ec36bed1f48c461605929c489c :: needs maintainer review before merge. :: none
  • reviewed 2026-10-25T19:23:28.427Z sha c5bbcba1451f8778a47839db2196670d3ae88686 :: needs changes before merge. :: [P2] Align snippet parsing with the normalized search query
  • reviewed 2026-10-27T04:25:10.180Z sha 325b729 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-27T21:20:44.467Z sha 5b63e12 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-27T21:54:59.631Z sha 1ea950c :: needs maintainer review before merge. :: none
  • reviewed 2026-10-27T22:23:56.772Z sha 26a81af :: needs maintainer review before merge. :: none

Reviewed October 27, 2026, 6:45 PM ET / 22:45 UTC (Revision 9).

@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 25, 2026
@lonexreb

Copy link
Copy Markdown
Contributor Author

Addressed the review on head 16cffaca6f4 (one commit on top of the reviewed ddeb057e53e, no production code change):

  • P2 wrapper inventory: scripts/pr-lib/wrapper-components.txt now lists src/state/openclaw-agent-text-search-migration.ts, placed with the other src/state/openclaw-agent-*-migration.ts entries. Checks run: pnpm test test/scripts/eager-import-closure.test.ts -t "PR wrapper inventory" — red without the entry (The trusted-anchor PR wrapper extracts only scripts/pr, scripts/pr-lib, and its inventory. naming src/state/openclaw-agent-text-search-migration.ts), green with it; then pnpm test test/scripts/eager-import-closure.test.ts test/scripts/pr-wrapper-source-closure.test.ts → 22/22.
  • P3 docs: docs/reference/database-engines.md now states that on agent schema 35 the stored tsvector is a plain column maintained by the <table>_search_sync trigger, also after the 34→35 migration, and that only historical stores used a generated column.
  • Latest-stable upgrade proof: attempted with npm [email protected] (agent schema 25) in an isolated state dir on PostgreSQL 16. That release has no database port command (database offers ownership, preflight, preflight-agent only), so no PostgreSQL agent store can exist on stable and there is nothing for this migration to upgrade; SQLite stores advance metadata only. The real PostgreSQL upgrade path is covered by doctor-migration.postgres.test.ts (keeps the real agent v27/v30/v31/v32/v33/v34→current rollback exact, 18/18 on PostgreSQL 17 + pgvector) and the new v34→v35 migration test on PostgreSQL 16. The body records this.

PR body updated with the above.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 25, 2026
@lonexreb

Copy link
Copy Markdown
Contributor Author

Addressed the remaining P2 on head 5527c38cd21 (one commit on top of 16cffaca6f4):

  • src/infra/database-engine/postgres-search.ts: the two batched-atom references (atom.text) and the phrase-list reference (search_terms.value) are fixed aliases of the statement's own recordsets, so they are now static SQL fragments (sql\atom.text`, sql`search_terms.value`) instead of sql.ref(...)`; generated SQL is unchanged.
  • Guard: node --import ./scripts/tsx.mjs scripts/check-kysely-guardrails.mts (the pnpm lint:kysely script) → Kysely guardrails OK, exit 0. On the previous head the same command reported the two postgres-search.ts:41/:42 violations.
  • Re-ran the PostgreSQL suites on PostgreSQL 17 + pgvector (search-extension, postgres-text-search-schema, postgres-search-admission, postgres-search.conformance, memory-public, session-search-product, memory-core manager-search.postgres, agent-port): 8 files / 59 tests passed, exit 0. PostgreSQL 16 keyword-only files pass; only the pgvector-capability cases fail there as before.
  • pnpm check:changed rerun: same three pre-existing rows (plugin SDK surface budget, dead-export scan, max-lines lint on untouched files); nothing new.

Body Evidence updated.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. labels Oct 25, 2026
@clawsweeper clawsweeper Bot removed the clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. label Oct 27, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. and removed merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 27, 2026
@steipete

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@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. 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 27, 2026
@steipete
steipete merged commit 338c811 into openclaw:main Oct 27, 2026
282 of 285 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
…search like SQLite FTS5 (openclaw#183547)

* fix(database): split punctuation-joined PostgreSQL full-text tokens like SQLite FTS5 (openclaw#183439)

PostgreSQL's text search parser keeps dates, paths, file names and a/b pairs as
single lexemes ('-08', 'server.py', '/v1/models', 'input/output'), so memory and
transcript keyword search missed words that SQLite FTS5 unicode61 matches.
On a real 44,740-chunk memory index the reporter measured hybrid top-1
relevance dropping from 15/40 on SQLite to 7/40 on PostgreSQL.

Text search version 2 replaces punctuation runs with spaces before to_tsvector
and before the query parser, for the stored vector and every tsquery path.
PostgreSQL 16 cannot replace a generated column's expression in place and
dropping the column would move it out of the sealed catalog position, so the
version 2 vector is maintained by a <table>_search_sync trigger with a backfill
UPDATE that is a no-op on fresh tables and indexes rows a port copied earlier.

The agent schema migration carries the cutover through the existing versioned
PostgreSQL migration: it drops the generated expression in place, installs the
trigger and reparses existing rows once for the transcript index and every
persisted search extension. SQLite advances version metadata only. Historical
admission and backup descriptors keep the generated column.

* fix(database): locate PostgreSQL snippets with the split query tokenization

Text search version 2 splits punctuation-joined words in the stored vector and
the query, but ts_headline still parsed the original field, where server.py is
one lexeme. A query for server.py became 'server' & 'py', found no match in the
headline parser and returned the opening words instead of the matching passage.

On version 2 stores the headline now parses the field with each punctuation
character replaced by one space. That keeps character offsets, so the selected
fragment is sliced back out of the original field and keeps its punctuation.
Version 1 stores keep the previous headline.

* test(database): share PostgreSQL store fixture lifecycle

* test(database): declare context-free fixture methods

---------

Co-authored-by: Peter Steinberger <[email protected]>
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 28, 2026
Absorbs openclaw/openclaw main at 8ea3ef8
(369 commits past U8 7fdf69f) into the j8 candidate 8183790.

16 textual conflicts, resolved upstream-first. Generated files were
regenerated (gateway:validators:gen, config:docs:gen, db:postgres:gen),
never hand-merged.

Agent schema collision: upstream openclaw#183547 took agent schema 38
(PostgreSQL text search splits punctuation-joined tokens; SQLite
metadata-only). Upstream keeps 38 byte-for-byte; continuation's
recipient-authority step is renumbered 38 -> 39 on top of it
(OPENCLAW_AGENT_SCHEMA_VERSION, package.json schemaVersions, the
authority constant, migration registry, port descriptor pin, backup
scopes, witness versions, schema history, regenerated catalogs).
On SQLite the authority step stays idempotent, so the j8 candidate's
schema-38 databases (upstream 38 plus the table) keep their rows.
PostgreSQL admission of the j8 candidate's 38 follows separately.

Refs karmaterminal/openclaw-bootstrap#1727
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 28, 2026
…t step 39

Jump 9 renumbered continuation's recipient-authority step 38 -> 39 on
top of upstream openclaw#183547's 38 (PostgreSQL text search splits
punctuation-joined tokens). A PostgreSQL agent store written by the
j8 candidate also reads 38 but is upstream's 37 plus the authority
table, without the text-search split. Step 39's declared predecessor
is upstream's 38, so the migration refused it as schema drift.

A PostgreSQL migration step may now list alternate exact
predecessors recorded at version - 1, each with the SQL that
converges it to the step's schema. The engine verifies the declared
source first, then each alternate; a failed check writes nothing (the
definition check runs under a savepoint), and with no match the
declared source's refusal stands unchanged. Step 39 lists the j8
shape: it keeps the authority table and rows and runs only upstream's
text-search conversion. Detection is by exact catalog, not version.

Accepted edge, documented: Doctor's pre-migration PostgreSQL export
loads the version-38 port descriptor (upstream's shape), so a j8
PostgreSQL store is refused at backup before any write; the fleet's
agent stores are SQLite. The earlier 35/36 candidates stay refused.

Fixtures (pinned pgvector pg16@sha256:7b822b0a...b90a, private port):
- jump-8 store with an authority row and transcript search ->
  39: rows kept, openclaw_search no longer generated, 'server.py'
  reparsed to 'py'/'server', catalog == fresh 39, reopen DDL-free;
- upstream 35/36/37/38 -> 39 in place, reopen DDL-free;
- 34 -> 39 chain; mixed 38 (split + table) refused byte-unchanged.
RED at e5c7bb0 (no alternate): the jump-8 case refused with
"PostgreSQL schema drift detected against generated DDL" (1/9).
GREEN: 9/9; with agent-port, text-search, agent-db and
doctor-migration PostgreSQL suites 53/53.

Refs karmaterminal/openclaw-bootstrap#1727
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: XL 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.

[Bug]: PostgreSQL memory keyword search misses tokens SQLite FTS matches (dates, paths, file names), so hybrid relevance regresses

3 participants