Skip to content

Commit daea62f

Browse files
steipetePick-cat
andauthored
fix(memory): search by filenames and paths
Co-authored-by: Pick-cat <[email protected]>
1 parent 96f0983 commit daea62f

25 files changed

Lines changed: 4244 additions & 159 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ Docs: https://docs.openclaw.ai
2929
### Fixes
3030

3131
- **Gateway service audit:** treat POSIX shell `-c` wrappers as opaque for the gateway-subcommand check, avoiding false missing-command warnings for shell-wrapped macOS LaunchAgents without parsing inner commands or ports. Fixes #81751. (#81778) Thanks @liaoandi.
32+
- **Memory filename search:** index paths separately from chunk bodies so exact full-path, basename, and stem queries rank the intended memory file first without changing body BM25 scores, snippets, or embeddings. (#96052, #94102) Thanks @Pick-cat.
3233
- **Outbound channel bootstrap:** suppress repeated failed plugin activation for the same channel, config, and registry generation while retrying after config or registry reloads. (#100377) Thanks @xialonglee.
3334
- **OpenAI Realtime client-secret deadlines:** bound voice and transcription secret acquisition to 30 seconds through the guarded fetch boundary while preserving authentication and bounded response parsing. (#102860) Thanks @Alix-007.
3435
- **Gateway client watchdog:** keep transport-stall detection active for unbounded and mixed pending requests so dead sockets reject pending requests, reconnect, and never replay rejected requests. (#103407) Thanks @NianJiuZst.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
93d27a7097760abb3da9c21e5d9429cb18089a582d022231204177ad6626d4d8 plugin-sdk-api-baseline.json
2-
67a222d06c5e922aae26ff23353c49f1794844381124f5e16f26ea8dd6137021 plugin-sdk-api-baseline.jsonl
1+
6f7e0f6f2e6d5b107500b62f9556abdc5e450eb80a7a8586c1baf7d82894ed2e plugin-sdk-api-baseline.json
2+
a3d7d4f1a3aff973cb59bac966f884a812cbc633f90a8d9cd793209192916e5c plugin-sdk-api-baseline.jsonl

‎docs/concepts/memory-search.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ flowchart LR
8282
machine running OpenClaw").
8383
- **BM25 keyword search** matches exact terms (IDs, error strings, config
8484
keys).
85+
- **Filename search** indexes paths separately from note bodies. Exact full
86+
paths, basenames, and filename stems rank ahead of partial path matches,
87+
while snippets and body keyword scores still come from note content.
8588

8689
If only one path is available, the other runs alone.
8790

‎docs/refactor/database-first.md‎

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ without exceptions outside doctor/import/export/debug boundaries.
191191
- No active session files.
192192
- No fake JSONL test fixtures except doctor legacy migration tests.
193193
- No raw SQLite access where Kysely is expected.
194-
- No new legacy DB migrations. This layout has not shipped; keep schema version
195-
at `1` unless there is a strong reason.
194+
- No new file-era DB migrations. The global schema remains at version `1`.
195+
The shipped per-agent version `1` schema has one bounded runtime migration to
196+
version `2` for stable memory-source identities.
196197

197198
## Code-Read Assumptions
198199

@@ -206,9 +207,9 @@ proceed with these assumptions:
206207
- Runtime compatibility files are not required. Legacy JSON and JSONL files are
207208
migration inputs only. The branch-local SQLite sidecars never shipped and are
208209
deleted instead of imported.
209-
- `openclaw doctor --fix` owns the legacy file-to-database migration step.
210-
Runtime startup and `openclaw migrate` should not carry legacy OpenClaw
211-
database-upgrade paths.
210+
- `openclaw doctor --fix` owns legacy file-to-database migration. Runtime
211+
startup owns only bounded upgrades between shipped SQLite schema versions;
212+
it must not import file-era state.
212213
- Credential compatibility follows the same rule: runtime credentials live in
213214
SQLite. Old `auth-profiles.json`, per-agent `auth.json`, and shared
214215
`credentials/oauth.json` files are doctor migration inputs, then removed
@@ -295,10 +296,10 @@ The branch already has a real shared SQLite base:
295296
- Runtime stores derive selected and inserted row types from those generated
296297
Kysely `DB` interfaces instead of shadowing SQLite row shapes by hand. Raw SQL
297298
remains limited to schema application, pragmas, and migration-only DDL.
298-
- The SQLite schemas are collapsed to `user_version = 1` because this database
299-
layout has not shipped yet. Runtime openers create the current schema only;
300-
file-to-database import remains in doctor code, and branch-local
301-
database upgrade helpers have been deleted.
299+
- The global SQLite schema remains at `user_version = 1`. The per-agent schema
300+
is at version `2`; its opener atomically migrates the shipped version `1`
301+
memory-source key to a stable integer identity. File-to-database import
302+
remains in doctor code.
302303
- Relational ownership is enforced where the ownership boundary is canonical:
303304
source migration rows cascade from `migration_runs`, task delivery state
304305
cascades from `task_runs`, and transcript identity rows cascade from
@@ -333,8 +334,9 @@ The branch already has a real shared SQLite base:
333334
`agent_databases` registry instead of reimplementing that query at each call
334335
site.
335336
- Global and per-agent databases record a `schema_meta` row with database role,
336-
schema version, timestamps, and agent id for agent databases. The layout still
337-
stays at `user_version = 1` because this SQLite schema has not shipped yet.
337+
schema version, timestamps, and agent id for agent databases. The global DB
338+
remains at `user_version = 1`; per-agent DBs use version `2` after the bounded
339+
memory-source identity migration.
338340
- Per-agent session identity now has a canonical `sessions` root table keyed by
339341
`session_id`, with `session_key`, `session_scope`, `account_id`,
340342
`primary_conversation_id`, timestamps, display fields, model metadata,
@@ -1498,13 +1500,15 @@ tool_artifacts(run_id, artifact_id, kind, metadata_json, blob, created_at)
14981500
run_artifacts(run_id, path, kind, metadata_json, blob, created_at)
14991501
trajectory_runtime_events(session_id, run_id, seq, event_json, created_at)
15001502
memory_index_meta(key, value)
1501-
memory_index_sources(path, source, hash, mtime, size)
1503+
memory_index_sources(id, path, source, hash, mtime, size)
15021504
memory_index_chunks(id, path, source, start_line, end_line, hash, model, text, embedding, updated_at)
15031505
memory_embedding_cache(provider, model, provider_key, hash, embedding, dims, updated_at)
15041506
memory_index_state(id, revision)
15051507
cache_entries(scope, key, value_json, blob, expires_at, updated_at)
15061508
```
15071509

1510+
`memory_index_sources.id` is the stable integer primary key; `(path, source)` remains unique.
1511+
15081512
Future search can add FTS tables without changing the canonical event tables:
15091513

15101514
```text
@@ -1824,9 +1828,9 @@ Backups remain one archive file:
18241828
`openclaw backup create` does this archive verification by default;
18251829
`--no-verify` skips only the post-write archive pass, not the snapshot
18261830
creation integrity check.
1827-
- Restore copies snapshots back to their target paths. This branch resets the
1828-
unshipped SQLite layout to `user_version = 1`; future shipped schema changes
1829-
can add explicit migrations when they are needed.
1831+
- Restore copies snapshots back to their target paths. Restored global DBs use
1832+
version `1`; restored per-agent DBs use version `2`, with version `1` snapshots
1833+
upgraded atomically when opened.
18301834

18311835
### Phase 6: Worker Runtime
18321836

@@ -1874,17 +1878,18 @@ agent id, schema version, source path, snapshot path, byte size, and integrity
18741878
status.
18751879

18761880
Restore should rebuild the global database and agent database files from the
1877-
archive snapshots. Because the SQLite layout has not shipped yet, this refactor
1878-
keeps only the version-1 schema plus doctor file-to-database import. The restore
1879-
command validates the archive first, then replaces each manifest asset from the
1880-
verified extracted payload.
1881+
archive snapshots. The global schema remains version `1`; per-agent version `1`
1882+
snapshots receive the bounded runtime upgrade to version `2`. Doctor remains
1883+
the only owner of file-to-database import. The restore command validates the
1884+
archive first, then replaces each manifest asset from the verified extracted
1885+
payload.
18811886

18821887
## Runtime Refactor Plan
18831888

18841889
1. Add database registry APIs.
18851890
- Resolve global DB and per-agent DB paths.
1886-
- Keep the unshipped schemas at `user_version = 1`; do not add schema
1887-
migration runner code until a shipped schema needs it.
1891+
- Keep the global schema at `user_version = 1`. Per-agent DBs use version `2`
1892+
with one atomic migration from the shipped version `1` memory-source shape.
18881893
- Add close/checkpoint/integrity helpers used by tests, backup, and doctor.
18891894

18901895
2. Collapse sidecar SQLite stores.

0 commit comments

Comments
 (0)