Skip to content

Feat/set payload by key - #3548

Merged
generall merged 26 commits into
qdrant:devfrom
Shylock-Hg:feat/set-payload-by-key
Feb 15, 2024
Merged

generall merged 26 commits into
qdrant:devfrom
Shylock-Hg:feat/set-payload-by-key

Conversation

@Shylock-Hg

@Shylock-Hg Shylock-Hg commented Feb 6, 2024 •

Copy link
Copy Markdown
Contributor

All Submissions:

  • Contributions should target the dev branch. Did you create your branch from dev?
  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Have you formatted your code locally using cargo +nightly fmt --all command prior to submission?
  3. Have you checked your code using cargo clippy --all --all-features command?

Changes to Core Features:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Close #3524
/claim #3524

@Shylock-Hg

Shylock-Hg commented Feb 6, 2024 •

Copy link
Copy Markdown
Contributor Author

@xzfc

xzfc commented Feb 7, 2024

Copy link
Copy Markdown
Member

this assertion failed, HTTP should return error when key is empty string.
I can't found the reason, could give me some tips?

@Shylock-Hg By default, this endpoint responds with HTTP 202 Accepted immediately while running its job in the background. You need to pass wait=true as a query parameter to get its result/error, like this:

@Shylock-Hg
Shylock-Hg marked this pull request as ready for review February 7, 2024 03:46
@Shylock-Hg

Copy link
Copy Markdown
Contributor Author

this assertion failed, HTTP should return error when key is empty string.
I can't found the reason, could give me some tips?

@Shylock-Hg By default, this endpoint responds with HTTP 202 Accepted immediately while running its job in the background. You need to pass wait=true as a query parameter to get its result/error, like this:

Thanks.

@Shylock-Hg

Copy link
Copy Markdown
Contributor Author

@generall Could take a look ?

@generall generall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Shylock-Hg, thanks for the PR!
I think interface matches our expectation, however there are a few problems with internals:

Proposed API change breaks guarantee of Idempotence.
In other words, sending same request twice produce different result and different state of the storage.

For example:

Assume point 123 have empty payload. When we do:

POST collections/test_collection/points/payload?wait=true
{
  "points": [123],
  "payload": {
    "a": 1
  },
  "key": "nested1"
}

It will generate point with:

 "payload": {
  "a": 1
}

But sending the same request twice will produce:

"error": "Wrong input: Can't find payload key segment: \"nested1\"."

Having Idempotence API is critical for Qdrant's distributed deployment mode and we can't ignore it.

On top of that there are a few other problems I will highlight in followup comments.

Comment thread lib/segment/src/types.rs Resolved
Comment thread lib/segment/src/types.rs Resolved
Comment thread lib/segment/src/types.rs Resolved
optional PointsSelector points_selector = 5; // Affected points
optional WriteOrdering ordering = 6; // Write ordering guarantees
optional ShardKeySelector shard_key_selector = 7; // Option for custom sharding to specify used shard keys
optional string key = 8; // Option for indicate property of payload

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would need to come up with better description for this field. (note mostly to myself)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I'm not good at english, do you have suggestion?

@Shylock-Hg

Copy link
Copy Markdown
Contributor Author

Hey @Shylock-Hg, thanks for the PR! I think interface matches our expectation, however there are a few problems with internals:

Proposed API change breaks guarantee of Idempotence. In other words, sending same request twice produce different result and different state of the storage.

For example:

Assume point 123 have empty payload. When we do:

POST collections/test_collection/points/payload?wait=true
{
  "points": [123],
  "payload": {
    "a": 1
  },
  "key": "nested1"
}

It will generate point with:

 "payload": {
  "a": 1
}

But sending the same request twice will produce:

"error": "Wrong input: Can't find payload key segment: \"nested1\"."

Having Idempotence API is critical for Qdrant's distributed deployment mode and we can't ignore it.

On top of that there are a few other problems I will highlight in followup comments.

Fine, I added it to tests.

@Shylock-Hg
Shylock-Hg requested a review from generall February 10, 2024 12:45
}
}
self.payload.borrow_mut().assign(point_id, payload)
if let Some(key) = key {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

key should be taken into account in case of index.add_point as well. Otherwise the values will be missing in the index.

@Shylock-Hg Shylock-Hg Feb 12, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I update index by updated payload now.

}
}

pub fn set_value_to_json_map<'a>(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this function requires explicit testing

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having openapi integration tests is nice, but it would be better to implement unit-tests here as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.

match self.payload.get_mut(&point_id) {
Some(point_payload) => point_payload.merge_by_key(payload, key)?,
None => {
self.payload.insert(point_id, payload.to_owned());

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic path ignores key, that will create a situation where idempotency will not be satisfied.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I plan to return error in this branch. WDYT?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I plan to return error in this branch

no, it is a valid request. You just need to merge empty payload with given

@Shylock-Hg Shylock-Hg Feb 12, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some problems,
e.g.
For request:

{
 "payload":{ ...}
 "key": "key1.key2[].key3"
}

What's the expected result to merge empty payload when there is nested key path and even array index?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as we would expect if stored payload doesn't have key1.key2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, it will construct value by default if key not exists.

@Shylock-Hg

Copy link
Copy Markdown
Contributor Author

@generall This lint error in CI job is a mistake, it's ok when I run in local machine, I never modify this file which report error.
https://github.com/qdrant/qdrant/actions/runs/7854889378/job/21452593460?pr=3548

@Shylock-Hg

Copy link
Copy Markdown
Contributor Author

@generall This linter seems wrong. I never modify related files in this PR.

error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
  --> lib/common/common/src/validation.rs:72:40
   |
72 | pub fn validate_geo_polygon<T>(points: &Vec<T>) -> Result<(), ValidationError>
   |                                        ^^^^^^^ help: change this to: `&[T]`
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg
   = note: `-D clippy::ptr-arg` implied by `-D warnings`
   = help: to override `-D warnings` add `#[allow(clippy::ptr_arg)]`

error: could not compile `common` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...

@xzfc
xzfc force-pushed the feat/set-payload-by-key branch from 6ff795a to bf41859 Compare February 15, 2024 06:47
@xzfc
xzfc changed the base branch from master to dev February 15, 2024 06:47
@xzfc
xzfc force-pushed the feat/set-payload-by-key branch from bf41859 to c36dcd4 Compare February 15, 2024 06:50
@xzfc

xzfc commented Feb 15, 2024

Copy link
Copy Markdown
Member

This linter seems wrong. I never modify related files in this PR.

@Shylock-Hg It probably was caused basing your PR on the master branch. You should target your PRs onto dev, not master. I've rebased your PR to dev.

@Shylock-Hg

Copy link
Copy Markdown
Contributor Author

This linter seems wrong. I never modify related files in this PR.

@Shylock-Hg It probably was caused basing your PR on the master branch. You should target your PRs onto dev, not master. I've rebased your PR to dev.

Thanks.

@generall generall left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once tests are green

@generall
generall requested a review from xzfc February 15, 2024 12:50
@generall
generall merged commit eff1fd8 into qdrant:dev Feb 15, 2024
@xzfc xzfc mentioned this pull request Feb 29, 2024
9 tasks done
timvisee pushed a commit that referenced this pull request Mar 5, 2024
* Support set by key in low level.

* Rename key field.

* Format.

* Pass key.

* Format.

* Test.

* Clippy.

* Fix ci lint.

* Check grpc consistency.

* Update openapi.

* Fix empty key test case.

* Support array index.

* Format.

* Add test for non exists key.

* Clippy fix.

* Add idempotence test.

* Update index by updated payload.

* Add ut for utils.

* Add ut for 1 level key.

* Fix ut.

* Support no exits key.

* Fix test result.

* Fix after rebase

* handle wildcart insertion into non-existing array

* avoid double read of payload during update

* fix missing removing data from index in case if set_payload removes indexed field

---------

Co-authored-by: Shylock Hg <shylock@DESKTOP-40I855A>
Co-authored-by: Albert Safin <[email protected]>
Co-authored-by: generall <[email protected]>
@Shylock-Hg
Shylock-Hg deleted the feat/set-payload-by-key branch March 29, 2024 01:20
Leela8256 added a commit to rocketride-org/rocketride-server that referenced this pull request Oct 20, 2026
The driver-fix bullet from 02f625d sat under the released [3.5.0]
section, but none of it shipped in 3.5.0, so a squash merge would have
added a false entry to those release notes. It now opens a Fixed section
under [Unreleased], after Changed.

The bullet also names what it left out. On Qdrant the trash update sets
only the nested flag (set_payload with key='meta'), which Qdrant added in
server 1.8.0 (qdrant/qdrant#3548), so soft_delete and restore need a 1.8
or newer server; the store_qdrant README now says so too. objdir now
returns paths on Chroma, which filtered on a 'chunk' key the store never
writes (so returned nothing) and, given a parent, sent a two-field where
that chromadb's validate_where rejects; and on Weaviate, which
subscripted a DocMetadata.

Astra is left out of the objdir list: its getPaths still calls
Collection.aggregate, which astrapy 2.3.1 does not have, and the stacked
astra-sdk-compatibility change carries its own bullet for that repair.

Refs #2587

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Leela8256 added a commit to rocketride-org/rocketride-server that referenced this pull request Oct 23, 2026
The driver-fix bullet from 02f625d sat under the released [3.5.0]
section, but none of it shipped in 3.5.0, so a squash merge would have
added a false entry to those release notes. It now opens a Fixed section
under [Unreleased], after Changed.

The bullet also names what it left out. On Qdrant the trash update sets
only the nested flag (set_payload with key='meta'), which Qdrant added in
server 1.8.0 (qdrant/qdrant#3548), so soft_delete and restore need a 1.8
or newer server; the store_qdrant README now says so too. objdir now
returns paths on Chroma, which filtered on a 'chunk' key the store never
writes (so returned nothing) and, given a parent, sent a two-field where
that chromadb's validate_where rejects; and on Weaviate, which
subscripted a DocMetadata.

Astra is left out of the objdir list: its getPaths still calls
Collection.aggregate, which astrapy 2.3.1 does not have, and the stacked
astra-sdk-compatibility change carries its own bullet for that repair.

Refs #2587

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Leela8256 added a commit to rocketride-org/rocketride-server that referenced this pull request Oct 24, 2026
The driver-fix bullet from 02f625d sat under the released [3.5.0]
section, but none of it shipped in 3.5.0, so a squash merge would have
added a false entry to those release notes. It now opens a Fixed section
under [Unreleased], after Changed.

The bullet also names what it left out. On Qdrant the trash update sets
only the nested flag (set_payload with key='meta'), which Qdrant added in
server 1.8.0 (qdrant/qdrant#3548), so soft_delete and restore need a 1.8
or newer server; the store_qdrant README now says so too. objdir now
returns paths on Chroma, which filtered on a 'chunk' key the store never
writes (so returned nothing) and, given a parent, sent a two-field where
that chromadb's validate_where rejects; and on Weaviate, which
subscripted a DocMetadata.

Astra is left out of the objdir list: its getPaths still calls
Collection.aggregate, which astrapy 2.3.1 does not have, and the stacked
astra-sdk-compatibility change carries its own bullet for that repair.

Refs #2587

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Leela8256 added a commit to rocketride-org/rocketride-server that referenced this pull request Oct 28, 2026
)

* feat(nodes): vector-store tools: trash, document listing, honest get and upsert numbering

Phase 2 of the vector-store tool surface (#2587), on the shared mixin every
store node on StoreInstanceBase carries, so all nine stores change together.

- soft_delete and restore: move documents to the trash and back over the
  drivers' existing markDeleted/markActive. Offered beside upsert and delete
  only while writes through tools are allowed, hidden from discovery otherwise.
  The abstract contract now returns Optional[int]; the two Postgres drivers
  return the statement's row count and the tools report it as matched_chunks,
  null where a driver gives none.
- list_documents: one entry per document (object_id, parent, chunk_count),
  ordered by object ID, paged with total and has_more, active or trash. It
  rides on an optional driver capability (DocumentStoreBase.listDocuments,
  countDocuments, supports_document_listing) that rocketride_vector and
  store_postgres implement; other drivers do not advertise the tool. stats
  gains document_count on the same capability.
- get answers an unknown object ID, or one in the trash, with a failure object
  instead of an empty page; stats loads the control row when a read-only task
  never did.
- upsert numbers the chunks sent for one object ID in the order given instead
  of storing them all as chunk 0, rejects an explicit chunkId that repeats
  within a call, and validates chunkId like the paging arguments. Every tool
  that takes object IDs refuses 'schema', the store's control row.
- Postgres get_paths pages by distinct parent, so objdir pages count paths
  and lists a document whatever its chunk IDs (#2668 item 2); the CHANGELOG
  names the nine stores (#2668 item 3).
- store_chroma's markDeleted/markActive never worked (they walked the dict a
  Chroma get returns as records and called an update(where=...) the client has
  no such form of); they now update the matched ids in one call, so the trash
  tools hold on that store too. One CONTROL_OBJECT_ID names the control row.

Docs: nine node READMEs, the rocketride_vector catalog text, a developer page
on the tool contract (docs/development/nodes/vector-store-tools.md), the
example template. Tests: one file per change on the mixin, a base-contract
test, a two-driver container suite for the SQL and the tools on a real store.

Refs #2587, #2668

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(nodes): preserve vector-store metadata and complete trash updates

* docs(nodes): clarify vector-store tools and retrieval limits

* test(store_milvus): stub only pymilvus in the getPaths trash test

The test loaded milvus.py inside patch.dict(sys.modules), which on exit
removes every module first imported inside the block. When numpy was not
already loaded, the first parametrization imported it and patch.dict
unloaded it again, so the next one failed with "cannot load module more
than once per process". Run alone, the directory failed 2 of 3 cases; in
the full suite something else had imported numpy first, which hid it.

monkeypatch.setitem now replaces only the pymilvus entry and restores it
after each case, so numpy and the ai modules stay loaded.

Refs #2587

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(changelog): list the vector-store driver fixes under Unreleased

The driver-fix bullet from 02f625d sat under the released [3.5.0]
section, but none of it shipped in 3.5.0, so a squash merge would have
added a false entry to those release notes. It now opens a Fixed section
under [Unreleased], after Changed.

The bullet also names what it left out. On Qdrant the trash update sets
only the nested flag (set_payload with key='meta'), which Qdrant added in
server 1.8.0 (qdrant/qdrant#3548), so soft_delete and restore need a 1.8
or newer server; the store_qdrant README now says so too. objdir now
returns paths on Chroma, which filtered on a 'chunk' key the store never
writes (so returned nothing) and, given a parent, sent a two-field where
that chromadb's validate_where rejects; and on Weaviate, which
subscripted a DocMetadata.

Astra is left out of the objdir list: its getPaths still calls
Collection.aggregate, which astrapy 2.3.1 does not have, and the stacked
astra-sdk-compatibility change carries its own bullet for that repair.

Refs #2587

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(store_astra): repair directory listing and bounded counts (#2725)

* test(nodes): install astrapy for the store_astra SDK test

test_active_paths.py imports astrapy before it imports astra_db, the module
whose depends() call is the only thing that installs it on a fresh engine. On
CI that import raced between xdist workers: the worker that had already
imported test_convert_filter.py (which loads astra_db) found astrapy, the
others did not, and pytest aborted the whole session with "Different tests
were collected". Listing astrapy with the other packages the tests import
directly installs it in nodes:install-test-deps, before collection.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* test(store_astra): say which astrapy the SDK test runs against

The docstring told readers to run this test with the astrapy version in
constraints.lock, which read as a version requirement and drew a review
suggestion to pin astrapy==2.2.1 in nodes/test/requirements.txt. The test
has no such requirement: depends() compiles its constraints per machine from
the nodes' unpinned requirement files and does not read constraints.lock
yet, so CI installed astrapy 2.3.2 and the suite passed. A pin would also be
unsatisfiable against those compiled constraints (uv: "you require
astrapy==2.2.1 and astrapy==2.3.1"). Unpinned, the test runs on the version
the store node gets at runtime, so an SDK change fails here before it
reaches a pipeline.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(nodes): address review of the vector-store trash and listing tools

- Chroma objdir uses the same trash predicate as get ($ne True), so a
  chunk-0 record without an isDeleted key is listed and a trashed one is
  not; test added
- Astra stats.count reports the server's estimate past the exact-count
  ceiling instead of paging every row ID on each call, floored at the
  count the refusal says was exceeded (the node's bound, or the server's
  limit as astrapy names it) since the estimate can lag recent writes; the
  README says count is approximate above the ceiling and that every objdir
  page scans all matching headers, so callers should ask for limit=1000
  and pass parent
- Weaviate trash drain pauses and sends a chunk once more if a read returns
  it after its update (a replica may lag) and fails instead of looping if
  it comes back again
- list_documents test: has_more follows the page read, not countDocuments
- CHANGELOG and the driver contract name Chroma among the stores reporting
  matched_chunks; the contract notes Milvus reads all matches in one query;
  Astra, Pinecone and Qdrant compare CONTROL_OBJECT_ID and its comment
  names the one remaining literal
- MIT headers on the four new test files; the astrapy protocol mock gains
  estimated_document_count

Review by Ariel Vernaza on #2704.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(store_qdrant): page objdir by offset and list every active chunk-0 record

Qdrant's scroll offset is a point-ID cursor, and this driver writes random
UUID point IDs, so an integer offset never moved the start: offsets 0, 1, 2
and 3 all returned the first page. getPaths now scrolls from the start with
limit=offset+limit and slices records[offset:], as the Pinecone driver does,
and the README says offset and limit count documents and that a page reads
offset + limit points. test_paths_page_by_offset_on_uuid_point_ids pins it
on the in-process backend with UUID point IDs.

getPaths required meta.isDeleted == False, so a chunk-0 point whose flag is
missing or null was hidden from objdir while get and search, which use
_convertFilter's must_not isDeleted == True, still read it. The condition
now sits in must_not next to the CONTROL_OBJECT_ID condition.
test_paths_list_records_without_a_deleted_flag_and_hide_trashed_ones pins
it, as the Chroma test does.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(store_chroma): count documents with Collection.count

count_documents, which stats reports as count, read every record ID in the
collection with get(include=[]) and returned len(ids), so each stats call
moved the whole collection's IDs. It now returns Collection.count(), the
server's count of the same records (every row, trashed ones and the control
row included, as "Rows (chunks) in the collection, as the store counts them"
promises). test_stats_count_asks_the_server_instead_of_reading_every_id pins
the count through count_documents and the stats tool and asserts no get is
sent; the fake collection gains count, and
test_the_fake_matches_the_installed_client pins its signature to chromadb's.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs(store_postgres,rocketride_vector): say objdir and list_documents scan the table

Neither table has an index on parent, objectId or isDeleted: both have
only the primary key on id, and rocketride_vector the hnsw index on
embedding. So each objdir page
runs DISTINCT ON (parent) over every active chunk, and each list_documents
page runs a GROUP BY objectId plus a COUNT(DISTINCT objectId) for total,
both as full scans. The objdir row of both READMEs now says every objdir
and list_documents page scans the whole table (list_documents a second
time for total) and to ask for large pages, as the Astra README does for
its scan. Documentation only; validate-node-readme passes on both nodes.

An index such as (parent, objectId, id) WHERE isDeleted = FALSE plus one
on (objectId) is a follow-up, not clearly right for this change:
PostgreSQL has no loose index scan, so DISTINCT ON would still read every
matching index entry and save the sort but not the pass; every insert
would pay for two more indexes; and on rocketride_vector it would mean
creating indexes on existing tables in the managed tenant database at
startup, which is a migration decision.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(store_weaviate): bound the trash drain by recounting pending chunks

The drain kept a Counter entry per chunk it touched and tolerated one 1 s
pause, so a replica showing writes 1.5 s late failed it. It now counts the
pending chunks with aggregate.over_all(filters=pending, total_count=True)
at the start and after each page: a lower count resets the stall counter,
an unchanged one pauses and counts a stall, and the third stall in a row
fails with the existing "partly applied, retry to finish" message; two
integers of state, one count query per page. Pinned by
test_trash_fails_on_alternating_stuck_pages (3 fetches, 2 pauses; 5ab7cbda
looped), test_trash_flips_the_rest_when_one_chunk_is_stuck and
test_trash_completes_on_a_replica_that_shows_writes_late (the Counter
failed it), each with a fetch bound; the stuck test now expects 9 attempts
and 2 pauses, the resend test no pause. The mock's over_all gains filters
and the driver contract describes the recount.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(nodes): report an unknown row count as None, not zero

markDeleted and markActive in store_postgres and rocketride_vector turned
psycopg2's rowcount of -1 (count not known) into 0, so soft_delete and
restore would have claimed that no chunk matched, against the contract that
a tool never claims a count the driver did not give. They now return None
there, which the tools report as matched_chunks null; for an UPDATE the
branch is practically dead, so nothing else changes.
test_trash_reports_the_row_count_and_none_when_it_is_unknown in
test_rocketride_db.py pins it for both drivers and both methods on the
existing fake cursor, which gains a rowcount (3, 0 and -1).

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs(nodes): align the vector-store tool text with the drivers

The mixin docstring said every tool is exposed as <serverName>.search and
that serverName prevents name collisions; agents address the tools as
<node id>.search and serverName only labels messages, as the services.json
and README edits already say. The class docstring and
_vectordb_server_name now say so.

The objdir parent schema text read as a prefix match; it now says the
drivers match exactly, Atlas as a case-insensitive pattern and Qdrant as a
text match, and the Atlas and Qdrant READMEs and the driver contract say
the same.

On Atlas, Chroma, Milvus, Pinecone and Weaviate the objdir offset and
limit count chunk-0 records, not paths; their README rows now say so and
that a page can hold fewer than limit entries while more follow, and the
contract names the two Postgres stores and Astra as the ones that count
paths.

The CHANGELOG Changed bullet described delete twice; it is one clause now.
The Fixed bullet also names this round's Qdrant objdir and Chroma stats
fixes.

The store_postgres README said "so the whole table is offered"; it now
says writes to the whole table are, and that expose_tools is likewise on
by default and undeclared.

get told a caller to restore a trashed document also on a node where
restore is hidden (rocketride_vector ships with writes off). The message
now names restore only while writes through tools are allowed and says the
node does not offer it otherwise, and the rocketride_vector README
describes both. test_the_trash_message_points_to_restore_only_where_it_is_offered
pins it; the other text changes are documentation, checked with
validate-node-readme on the eight nodes whose README changed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* test(nodes): drop the phase-2 wording from the vector-store test docstrings

Ten docstrings added by this PR carried "phase 2", a planning label that
means nothing once the change is merged; "(#2587)" says where they come
from. Wording only: the docstrings of the eight shared-store test files,
store_chroma/test_mark_deleted.py and test_vector_store_listing_full.py;
no test changes, and every suite passes as before.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(store_qdrant): read objdir pages in bounded scroll requests

A collection can cap the size of one scroll request (max_query_limit), and
the previous commit asked for offset + limit points in a single request, so
a large offset could be refused even when the requested page was small. The
page is now read in requests of at most _OBJDIR_SCROLL_PAGE (1,000) points
that follow next_page_offset, and only the requested slice is kept. The cost
of a page is unchanged, offset + limit points; no single request exceeds the
cap. The README says so. Pinned by
test_paths_read_offset_pages_in_bounded_scroll_requests, which lowers the
page size to two, records every request's limit and checks the pages and
the request sizes; it fails when the page is asked for in one request.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* test(store_qdrant): expect the request sizes the page size implies

The bounded-scroll test asserted three requests of 2, 2 and 1 for a default
listing of five points, but the driver asks for the smaller of the page size
and what is still wanted, and with the default limit of 1,000 that is two
each time; the third request simply gets the last point and no
next_page_offset. The expectation now follows the driver: 2, 2, 2 for the
default listing and 2, 2, 1 for offset 3 with limit 2, where only one point
is still wanted. CI on macOS caught the wrong expectation.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
AviNormie pushed a commit to AviNormie/rocketride-server that referenced this pull request Nov 9, 2026
…cketride-org#2704)

* feat(nodes): vector-store tools: trash, document listing, honest get and upsert numbering

Phase 2 of the vector-store tool surface (rocketride-org#2587), on the shared mixin every
store node on StoreInstanceBase carries, so all nine stores change together.

- soft_delete and restore: move documents to the trash and back over the
  drivers' existing markDeleted/markActive. Offered beside upsert and delete
  only while writes through tools are allowed, hidden from discovery otherwise.
  The abstract contract now returns Optional[int]; the two Postgres drivers
  return the statement's row count and the tools report it as matched_chunks,
  null where a driver gives none.
- list_documents: one entry per document (object_id, parent, chunk_count),
  ordered by object ID, paged with total and has_more, active or trash. It
  rides on an optional driver capability (DocumentStoreBase.listDocuments,
  countDocuments, supports_document_listing) that rocketride_vector and
  store_postgres implement; other drivers do not advertise the tool. stats
  gains document_count on the same capability.
- get answers an unknown object ID, or one in the trash, with a failure object
  instead of an empty page; stats loads the control row when a read-only task
  never did.
- upsert numbers the chunks sent for one object ID in the order given instead
  of storing them all as chunk 0, rejects an explicit chunkId that repeats
  within a call, and validates chunkId like the paging arguments. Every tool
  that takes object IDs refuses 'schema', the store's control row.
- Postgres get_paths pages by distinct parent, so objdir pages count paths
  and lists a document whatever its chunk IDs (rocketride-org#2668 item 2); the CHANGELOG
  names the nine stores (rocketride-org#2668 item 3).
- store_chroma's markDeleted/markActive never worked (they walked the dict a
  Chroma get returns as records and called an update(where=...) the client has
  no such form of); they now update the matched ids in one call, so the trash
  tools hold on that store too. One CONTROL_OBJECT_ID names the control row.

Docs: nine node READMEs, the rocketride_vector catalog text, a developer page
on the tool contract (docs/development/nodes/vector-store-tools.md), the
example template. Tests: one file per change on the mixin, a base-contract
test, a two-driver container suite for the SQL and the tools on a real store.

Refs rocketride-org#2587, rocketride-org#2668

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(nodes): preserve vector-store metadata and complete trash updates

* docs(nodes): clarify vector-store tools and retrieval limits

* test(store_milvus): stub only pymilvus in the getPaths trash test

The test loaded milvus.py inside patch.dict(sys.modules), which on exit
removes every module first imported inside the block. When numpy was not
already loaded, the first parametrization imported it and patch.dict
unloaded it again, so the next one failed with "cannot load module more
than once per process". Run alone, the directory failed 2 of 3 cases; in
the full suite something else had imported numpy first, which hid it.

monkeypatch.setitem now replaces only the pymilvus entry and restores it
after each case, so numpy and the ai modules stay loaded.

Refs rocketride-org#2587

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* docs(changelog): list the vector-store driver fixes under Unreleased

The driver-fix bullet from 02f625d sat under the released [3.5.0]
section, but none of it shipped in 3.5.0, so a squash merge would have
added a false entry to those release notes. It now opens a Fixed section
under [Unreleased], after Changed.

The bullet also names what it left out. On Qdrant the trash update sets
only the nested flag (set_payload with key='meta'), which Qdrant added in
server 1.8.0 (qdrant/qdrant#3548), so soft_delete and restore need a 1.8
or newer server; the store_qdrant README now says so too. objdir now
returns paths on Chroma, which filtered on a 'chunk' key the store never
writes (so returned nothing) and, given a parent, sent a two-field where
that chromadb's validate_where rejects; and on Weaviate, which
subscripted a DocMetadata.

Astra is left out of the objdir list: its getPaths still calls
Collection.aggregate, which astrapy 2.3.1 does not have, and the stacked
astra-sdk-compatibility change carries its own bullet for that repair.

Refs rocketride-org#2587

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(store_astra): repair directory listing and bounded counts (rocketride-org#2725)

* test(nodes): install astrapy for the store_astra SDK test

test_active_paths.py imports astrapy before it imports astra_db, the module
whose depends() call is the only thing that installs it on a fresh engine. On
CI that import raced between xdist workers: the worker that had already
imported test_convert_filter.py (which loads astra_db) found astrapy, the
others did not, and pytest aborted the whole session with "Different tests
were collected". Listing astrapy with the other packages the tests import
directly installs it in nodes:install-test-deps, before collection.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* test(store_astra): say which astrapy the SDK test runs against

The docstring told readers to run this test with the astrapy version in
constraints.lock, which read as a version requirement and drew a review
suggestion to pin astrapy==2.2.1 in nodes/test/requirements.txt. The test
has no such requirement: depends() compiles its constraints per machine from
the nodes' unpinned requirement files and does not read constraints.lock
yet, so CI installed astrapy 2.3.2 and the suite passed. A pin would also be
unsatisfiable against those compiled constraints (uv: "you require
astrapy==2.2.1 and astrapy==2.3.1"). Unpinned, the test runs on the version
the store node gets at runtime, so an SDK change fails here before it
reaches a pipeline.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(nodes): address review of the vector-store trash and listing tools

- Chroma objdir uses the same trash predicate as get ($ne True), so a
  chunk-0 record without an isDeleted key is listed and a trashed one is
  not; test added
- Astra stats.count reports the server's estimate past the exact-count
  ceiling instead of paging every row ID on each call, floored at the
  count the refusal says was exceeded (the node's bound, or the server's
  limit as astrapy names it) since the estimate can lag recent writes; the
  README says count is approximate above the ceiling and that every objdir
  page scans all matching headers, so callers should ask for limit=1000
  and pass parent
- Weaviate trash drain pauses and sends a chunk once more if a read returns
  it after its update (a replica may lag) and fails instead of looping if
  it comes back again
- list_documents test: has_more follows the page read, not countDocuments
- CHANGELOG and the driver contract name Chroma among the stores reporting
  matched_chunks; the contract notes Milvus reads all matches in one query;
  Astra, Pinecone and Qdrant compare CONTROL_OBJECT_ID and its comment
  names the one remaining literal
- MIT headers on the four new test files; the astrapy protocol mock gains
  estimated_document_count

Review by Ariel Vernaza on rocketride-org#2704.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(store_qdrant): page objdir by offset and list every active chunk-0 record

Qdrant's scroll offset is a point-ID cursor, and this driver writes random
UUID point IDs, so an integer offset never moved the start: offsets 0, 1, 2
and 3 all returned the first page. getPaths now scrolls from the start with
limit=offset+limit and slices records[offset:], as the Pinecone driver does,
and the README says offset and limit count documents and that a page reads
offset + limit points. test_paths_page_by_offset_on_uuid_point_ids pins it
on the in-process backend with UUID point IDs.

getPaths required meta.isDeleted == False, so a chunk-0 point whose flag is
missing or null was hidden from objdir while get and search, which use
_convertFilter's must_not isDeleted == True, still read it. The condition
now sits in must_not next to the CONTROL_OBJECT_ID condition.
test_paths_list_records_without_a_deleted_flag_and_hide_trashed_ones pins
it, as the Chroma test does.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(store_chroma): count documents with Collection.count

count_documents, which stats reports as count, read every record ID in the
collection with get(include=[]) and returned len(ids), so each stats call
moved the whole collection's IDs. It now returns Collection.count(), the
server's count of the same records (every row, trashed ones and the control
row included, as "Rows (chunks) in the collection, as the store counts them"
promises). test_stats_count_asks_the_server_instead_of_reading_every_id pins
the count through count_documents and the stats tool and asserts no get is
sent; the fake collection gains count, and
test_the_fake_matches_the_installed_client pins its signature to chromadb's.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs(store_postgres,rocketride_vector): say objdir and list_documents scan the table

Neither table has an index on parent, objectId or isDeleted: both have
only the primary key on id, and rocketride_vector the hnsw index on
embedding. So each objdir page
runs DISTINCT ON (parent) over every active chunk, and each list_documents
page runs a GROUP BY objectId plus a COUNT(DISTINCT objectId) for total,
both as full scans. The objdir row of both READMEs now says every objdir
and list_documents page scans the whole table (list_documents a second
time for total) and to ask for large pages, as the Astra README does for
its scan. Documentation only; validate-node-readme passes on both nodes.

An index such as (parent, objectId, id) WHERE isDeleted = FALSE plus one
on (objectId) is a follow-up, not clearly right for this change:
PostgreSQL has no loose index scan, so DISTINCT ON would still read every
matching index entry and save the sort but not the pass; every insert
would pay for two more indexes; and on rocketride_vector it would mean
creating indexes on existing tables in the managed tenant database at
startup, which is a migration decision.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(store_weaviate): bound the trash drain by recounting pending chunks

The drain kept a Counter entry per chunk it touched and tolerated one 1 s
pause, so a replica showing writes 1.5 s late failed it. It now counts the
pending chunks with aggregate.over_all(filters=pending, total_count=True)
at the start and after each page: a lower count resets the stall counter,
an unchanged one pauses and counts a stall, and the third stall in a row
fails with the existing "partly applied, retry to finish" message; two
integers of state, one count query per page. Pinned by
test_trash_fails_on_alternating_stuck_pages (3 fetches, 2 pauses; 5ab7cbda
looped), test_trash_flips_the_rest_when_one_chunk_is_stuck and
test_trash_completes_on_a_replica_that_shows_writes_late (the Counter
failed it), each with a fetch bound; the stuck test now expects 9 attempts
and 2 pauses, the resend test no pause. The mock's over_all gains filters
and the driver contract describes the recount.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(nodes): report an unknown row count as None, not zero

markDeleted and markActive in store_postgres and rocketride_vector turned
psycopg2's rowcount of -1 (count not known) into 0, so soft_delete and
restore would have claimed that no chunk matched, against the contract that
a tool never claims a count the driver did not give. They now return None
there, which the tools report as matched_chunks null; for an UPDATE the
branch is practically dead, so nothing else changes.
test_trash_reports_the_row_count_and_none_when_it_is_unknown in
test_rocketride_db.py pins it for both drivers and both methods on the
existing fake cursor, which gains a rowcount (3, 0 and -1).

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* docs(nodes): align the vector-store tool text with the drivers

The mixin docstring said every tool is exposed as <serverName>.search and
that serverName prevents name collisions; agents address the tools as
<node id>.search and serverName only labels messages, as the services.json
and README edits already say. The class docstring and
_vectordb_server_name now say so.

The objdir parent schema text read as a prefix match; it now says the
drivers match exactly, Atlas as a case-insensitive pattern and Qdrant as a
text match, and the Atlas and Qdrant READMEs and the driver contract say
the same.

On Atlas, Chroma, Milvus, Pinecone and Weaviate the objdir offset and
limit count chunk-0 records, not paths; their README rows now say so and
that a page can hold fewer than limit entries while more follow, and the
contract names the two Postgres stores and Astra as the ones that count
paths.

The CHANGELOG Changed bullet described delete twice; it is one clause now.
The Fixed bullet also names this round's Qdrant objdir and Chroma stats
fixes.

The store_postgres README said "so the whole table is offered"; it now
says writes to the whole table are, and that expose_tools is likewise on
by default and undeclared.

get told a caller to restore a trashed document also on a node where
restore is hidden (rocketride_vector ships with writes off). The message
now names restore only while writes through tools are allowed and says the
node does not offer it otherwise, and the rocketride_vector README
describes both. test_the_trash_message_points_to_restore_only_where_it_is_offered
pins it; the other text changes are documentation, checked with
validate-node-readme on the eight nodes whose README changed.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* test(nodes): drop the phase-2 wording from the vector-store test docstrings

Ten docstrings added by this PR carried "phase 2", a planning label that
means nothing once the change is merged; "(rocketride-org#2587)" says where they come
from. Wording only: the docstrings of the eight shared-store test files,
store_chroma/test_mark_deleted.py and test_vector_store_listing_full.py;
no test changes, and every suite passes as before.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* fix(store_qdrant): read objdir pages in bounded scroll requests

A collection can cap the size of one scroll request (max_query_limit), and
the previous commit asked for offset + limit points in a single request, so
a large offset could be refused even when the requested page was small. The
page is now read in requests of at most _OBJDIR_SCROLL_PAGE (1,000) points
that follow next_page_offset, and only the requested slice is kept. The cost
of a page is unchanged, offset + limit points; no single request exceeds the
cap. The README says so. Pinned by
test_paths_read_offset_pages_in_bounded_scroll_requests, which lowers the
page size to two, records every request's limit and checks the pages and
the request sizes; it fails when the page is asked for in one request.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

* test(store_qdrant): expect the request sizes the page size implies

The bounded-scroll test asserted three requests of 2, 2 and 1 for a default
listing of five points, but the driver asks for the smaller of the page size
and what is still wanted, and with the default limit of 1,000 that is two
each time; the third request simply gets the last point and no
next_page_offset. The expectation now follows the driver: 2, 2, 2 for the
default listing and 2, 2, 1 for offset 3 with limit 2, where only one point
is still wanted. CI on macOS caught the wrong expectation.

Co-Authored-By: Claude Fable 5.1 <[email protected]>

---------

Co-authored-by: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support JsonPath in update payload commands

3 participants