Skip to content

chore: PRO-1122: merge main into data-governance (30 Nov) [kyle-agent] - #269

Merged
kyleking-cohere merged 13 commits into
data-governancefrom
kyle/pro-1122-merge-main-30nov
Nov 30, 2026
Merged

kyleking-cohere merged 13 commits into
data-governancefrom
kyle/pro-1122-merge-main-30nov

Conversation

@kyleking-cohere

Copy link
Copy Markdown

Part of PRO-1122

Merges main (12 commits, through 2.28.1: group_scopes, count, upload extensions) into data-governance as a real two-parent merge. It lands by fast-forward like the last sync.

Conflict resolutions

  • search_documents, search_chunks and direct_search (sync and async clients) take both permit and main's group_scopes. SearchInput and DirectSearchInput carry both governance and group_scopes.
  • pyproject.toml: main's version, 2.28.1.

Governance fix: main's new count takes permit (CountInput.governance), because Compass's _count now needs a permit while governance is on (compass#4205). count joins the test_governance cases.

Tested: ruff, and the full unit suite (596 pass).

corafid and others added 13 commits October 16, 2026 01:56
# Overview

Ensure that we support Python 3.14 and Python 3.15. Our
[pyproject.toml](https://github.com/cohere-ai/cohere-compass-sdk/blob/f03ed997894b13131879d08ff3627ffec438fb64/pyproject.toml#L13)
already supports versions 3.11 and later, so this change is mostly about
updating the workflows to cover Python 3.14 and 3.15.
Fix the broken API reference link in README
Bumps [certifi](https://github.com/certifi/python-certifi) from
2026.2.25 to 2026.10.19.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/certifi/python-certifi/commit/662df63d7906df66f1f07c0751a3dfe9da14d914"><code>662df63</code></a>
Restore unaffected emSign roots (<a
href="https://redirect.github.com/certifi/python-certifi/issues/439">#439</a>)
(<a
href="https://redirect.github.com/certifi/python-certifi/issues/440">#440</a>)</li>
<li><a
href="https://github.com/certifi/python-certifi/commit/5cb238caeeb6c30ec1a7309ad3e16a5aa7b10ce8"><code>5cb238c</code></a>
Remove emsign (<a
href="https://redirect.github.com/certifi/python-certifi/issues/437">#437</a>)</li>
<li><a
href="https://github.com/certifi/python-certifi/commit/69494a764d0a08f90838d53d4b0fefd3e84045d6"><code>69494a7</code></a>
Bump actions/download-artifact from 8.0.1 to 8.0.2 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/436">#436</a>)</li>
<li><a
href="https://github.com/certifi/python-certifi/commit/029c7b0913d79e2efb73a216fc5c5e13ef958536"><code>029c7b0</code></a>
Bump actions/upload-artifact from 7.0.1 to 7.0.2 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/435">#435</a>)</li>
<li><a
href="https://github.com/certifi/python-certifi/commit/9d0a8f1f3a0d6b2e38d5773db7afe1a37e4527b6"><code>9d0a8f1</code></a>
Add support for Python 3.15 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/432">#432</a>)</li>
<li><a
href="https://github.com/certifi/python-certifi/commit/db472abf0a37067cb4488f036f4c19adf6b6ec3c"><code>db472ab</code></a>
Bump pypa/gh-action-pypi-publish from 1.14.1 to 1.14.2 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/431">#431</a>)</li>
<li><a
href="https://github.com/certifi/python-certifi/commit/f4bc676bc101fe2235846e37044e8c693d6cbaf4"><code>f4bc676</code></a>
2026.07.22 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/428">#428</a>)</li>
<li><a
href="https://github.com/certifi/python-certifi/commit/4c91f9c5f9b4676d40d2930025ba04d80dd536f6"><code>4c91f9c</code></a>
Bump actions/setup-python from 6.3.0 to 7.0.0 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/427">#427</a>)</li>
<li><a
href="https://github.com/certifi/python-certifi/commit/01a66c5cf32eadb8f03a0504c24cb44f6d581248"><code>01a66c5</code></a>
Bump actions/checkout from 7.0.0 to 7.0.1 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/426">#426</a>)</li>
<li><a
href="https://github.com/certifi/python-certifi/commit/eb355f41cb71f71012ecf1a4d27a57d0ee2b1337"><code>eb355f4</code></a>
Bump pypa/gh-action-pypi-publish from 1.14.0 to 1.14.1 (<a
href="https://redirect.github.com/certifi/python-certifi/issues/425">#425</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/certifi/python-certifi/compare/2026.02.25...2026.10.19">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=certifi&package-manager=pip&previous-version=2026.2.25&new-version=2026.10.19)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/cohere-ai/cohere-compass-sdk/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [filelock](https://github.com/tox-dev/py-filelock) from 3.25.2 to
4.2.1.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/tox-dev/py-filelock/releases">filelock's
releases</a>.</em></p>
<blockquote>
<h2>4.2.1</h2>
<ul>
<li>On a singleton wrapper, <code>close&gt;</code> and
<code>close&gt;</code> end only the holds that tasks acquired
through that wrapper. A reader that arrives during <code>close()</code>
gets the closed error instead of joining the ending hold.
After synchronous code closes or force-releases the shared lock, the
wrappers refuse to admit readers into the ended
hold, and <code>close()</code> on such a wrapper returns.
Closing one wrapper no longer ends a task's nested hold taken through
another wrapper on the same path. <a
href="https://redirect.github.com/tox-dev/py-filelock/issues/832">#832</a></li>
<li><code>ReadWriteLock</code> locks again after a
<code>release()</code> that an exception from a signal handler
interrupted.
The async read-write wrappers stop admitting readers into such a level.
The async read-write locks forget a hold whose
backend release failed after the backend let go, and they free the
memory of each acquire that times out or is canceled.
<code>AsyncFileLock</code> returns from <code>release()</code> after a
few hundred acquires gave up behind a waiting one. An exception from a
signal handler delivered while an <code>AsyncFileLock</code> call joins
its queue no longer blocks every later call on that lock. <a
href="https://redirect.github.com/tox-dev/py-filelock/issues/833">#833</a></li>
<li>Fix <code>ReadWriteLock</code> acting on <code>-journal</code>,
<code>-wal</code> or <code>-shm</code> files another process puts beside
its
database: a write could land in another file, a reader could get in
beside a writer, and an acquire could fail. SQLite
now opens the database by name only in a directory no other account can
write, and through a private hard link
elsewhere. On Windows the directory's access control list decides. Where
hard links are unavailable, keep the database
in a directory other accounts cannot write, such as one under
<code>%LOCALAPPDATA%</code>. The lock removes link directories
through a checked descriptor rather than by name, reads a link
directory's name only when the locking account owns it,
and leaves alone a directory with other content renamed onto a link
directory's name. A database whose schema takes more
than a few kilobytes to load raises <code>ValueError</code> instead of
running past the acquire timeout. <a
href="https://redirect.github.com/tox-dev/py-filelock/issues/834">#834</a></li>
<li>Fix five bugs in opening the lock file. <code>UnixFileLock</code> no
longer truncates a file it did not create,
such as one renamed to the lock path, and no longer applies
<code>mode</code> to it. An <code>on_acquired</code> hook that writes
holder
metadata now truncates the file itself. A lease (Linux) or an oplock
(Windows) on the lock file or a soft lock's marker
no longer holds <code>acquire()</code> past its <code>timeout</code> or
<code>blocking=False</code>, and an oplock no longer holds
<code>release()</code>;
<code>ReadWriteLock</code> on Windows waits for its <code>timeout</code>
and raises <code>Timeout</code>. On Windows,
a <code>mode</code> without group and other bits, such as
<code>0o600</code>, now creates the lock file with an owner-only
permission
list; the <code>ReadWriteLock</code> database gets the same. The soft
locks' writability check no longer follows a
symlink swapped in at the lock path. On a filesystem without
<code>flock</code>, a contender from another account now waits on a
marker it cannot write instead of raising <code>PermissionError</code>.
<a
href="https://redirect.github.com/tox-dev/py-filelock/issues/835">#835</a></li>
<li>Fix <code>SoftFileLock</code>, <code>MarkerSoftFileLock</code> and
<code>SoftFileLease</code> removing
a live holder's marker in three cases: the holder and the contender run
in Linux time namespaces with different boottime
offsets; only one of them can read the boot id; a process other than the
owner rewrote the marker. Soft markers no
longer carry group or other write bits. A process name containing a
carriage return or another line separator no longer
makes the stale check raise <code>ValueError</code>. When
<code>/proc/self/ns/time</code> exists but cannot be read, the stale
check
no longer compares start times and keeps the marker. <a
href="https://redirect.github.com/tox-dev/py-filelock/issues/836">#836</a></li>
<li>The async read-write locks record their hold under a task owner, so
synchronous code on the executor thread that took
the hold can no longer re-enter or release it.
<code>AsyncSoftReadWriteLock</code> gives back one level on
release, so synchronous readers of a shared singleton keep theirs.
<code>SoftReadWriteLock</code> tracks read
levels per thread: <code>release()</code> from a thread that holds none
raises <code>RuntimeError</code>. After its heartbeat
recorded a lost hold, it refuses new acquires until that hold is
released. <a
href="https://redirect.github.com/tox-dev/py-filelock/issues/838">#838</a></li>
<li><code>StrictSoftFileLock</code> creates
<code>&lt;path&gt;.filelock</code> and its <code>claims</code> directory
with the lock's <code>mode</code>
and sets the sticky bit (a directory flag that lets only a file's owner
remove it) on both. On the next acquisition it
narrows a directory it owns that an earlier release created wider; it
leaves a directory of another account as it is,
so remove such leftovers by hand. It reaches <code>claims</code> through
a descriptor opened without following symlinks; on
Windows it holds both directories open and refuses a junction (a
directory that points at another directory). Under a
sticky parent such as <code>/tmp</code> it refuses a coordination
directory of another account, as
<code>SoftReadWriteLock</code> does for <code>&lt;path&gt;.rw</code>.
One read grace now covers a whole claim scan, a failed
claim cleanup no longer leaves the sentinel descriptor open, and a
non-regular node at a sentinel private-record name
raises <code>SoftFileLockProtocolError</code>. On Windows, contenders
read claims without blocking their owner's
unlink. <a
href="https://redirect.github.com/tox-dev/py-filelock/issues/839">#839</a></li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/tox-dev/filelock/blob/main/docs/changelog.rst">filelock's
changelog</a>.</em></p>
<blockquote>
<p>###########
Changelog
###########</p>
<p>.. towncrier-draft-entries:: Unreleased</p>
<p>.. towncrier release notes start</p>
<hr />
<p>4.2.4 (2026-10-19)</p>
<hr />
<ul>
<li>Keep GitHub Release notes free of extra blank lines while retaining
the PyPI and version comparison links. :pr:<code>863</code></li>
</ul>
<hr />
<p>4.2.3 (2026-10-19)</p>
<hr />
<ul>
<li>Creating a lock on a Python 3.15 interpreter without
<code>types.LazyImportType</code> no longer triggers
<code>AttributeError</code> at
exit. :pr:<code>860</code></li>
<li>Handle <code>EFTYPE</code> when a no-follow open refuses a symlink
in a soft reader/writer lock's protocol tree, so heartbeat
reports lost ownership rather than a transient refresh error.</li>
</ul>
<hr />
<p>4.2.2 (2026-10-18)</p>
<hr />
<ul>
<li>Fix a lock on a relative path that stayed held after a later
<code>with lock:</code> ended, when an earlier <code>acquire()</code>
had
failed because the working directory no longer exists. That call still
raises :class:<code>FileNotFoundError</code>, and it now
leaves the lock's hold count unchanged. :pr:<code>856</code></li>
</ul>
<hr />
<p>4.2.1 (2026-10-17)</p>
<hr />
<ul>
<li>On a singleton wrapper, :meth:<code>AsyncReadWriteLock.close()
&lt;filelock.AsyncReadWriteLock.close&gt;</code> and
:meth:<code>AsyncSoftReadWriteLock.close()
&lt;filelock.AsyncSoftReadWriteLock.close&gt;</code> end only the holds
that tasks acquired
through that wrapper. A reader that arrives during <code>close()</code>
gets the closed error instead of joining the ending hold.
After synchronous code closes or force-releases the shared lock, the
wrappers refuse to admit readers into the ended
hold, and <code>close()</code> on such a wrapper returns.
Closing one wrapper no longer ends a task's nested hold taken through
another wrapper on the same path. :pr:<code>832</code></li>
<li>:class:<code>~filelock.ReadWriteLock</code> locks again after a
<code>release()</code> that an exception from a signal handler
interrupted.
The async read-write wrappers stop admitting readers into such a level.
The async read-write locks forget a hold whose
backend release failed after the backend let go, and they free the
memory of each acquire that times out or is canceled.
:class:<code>~filelock.AsyncFileLock</code> returns from
<code>release()</code> after a few hundred acquires gave up behind a
waiting one. An exception from a signal handler delivered while an
:class:<code>~filelock.AsyncFileLock</code> call joins
its queue no longer blocks every later call on that lock.
:pr:<code>833</code></li>
<li>Fix :class:<code>~filelock.ReadWriteLock</code> acting on
<code>-journal</code>, <code>-wal</code> or <code>-shm</code> files
another process puts beside its
database: a write could land in another file, a reader could get in
beside a writer, and an acquire could fail. SQLite
now opens the database by name only in a directory no other account can
write, and through a private hard link
elsewhere. On Windows the directory's access control list decides. Where
hard links are unavailable, keep the database</li>
</ul>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/tox-dev/filelock/commit/60331bb89f325020b48bc51bde904c6446384e4a"><code>60331bb</code></a>
Release 4.2.1</li>
<li><a
href="https://github.com/tox-dev/filelock/commit/834bf130760b2672615510f0288af1e1dcb7467c"><code>834bf13</code></a>
🧪 test(soft): skip Unix pin test on Windows</li>
<li><a
href="https://github.com/tox-dev/filelock/commit/9d15e38e50f7dd7f318e912d3bcd5f7697c3f8a1"><code>9d15e38</code></a>
fix(soft-rw): isolate subclass singleton registries (<a
href="https://redirect.github.com/tox-dev/py-filelock/issues/855">#855</a>)</li>
<li><a
href="https://github.com/tox-dev/filelock/commit/e1e825b1992f69fb6b346dc395d5ae4893536c0a"><code>e1e825b</code></a>
🐛 fix(open): keep lock files intact, honor deadlines and mode (<a
href="https://redirect.github.com/tox-dev/py-filelock/issues/835">#835</a>)</li>
<li><a
href="https://github.com/tox-dev/filelock/commit/5e3f2ec0c5fb17cb2635b60b2b68bc63ab81ca2d"><code>5e3f2ec</code></a>
🐛 fix(read-write): keep SQLite off shared names, bound schema (<a
href="https://redirect.github.com/tox-dev/py-filelock/issues/834">#834</a>)</li>
<li><a
href="https://github.com/tox-dev/filelock/commit/bfa066d65a1ba9106f86ee9d027f7588b9c77e03"><code>bfa066d</code></a>
🐛 fix(strict): keep claim directories private to the lock (<a
href="https://redirect.github.com/tox-dev/py-filelock/issues/839">#839</a>)</li>
<li><a
href="https://github.com/tox-dev/filelock/commit/977d2c3990d2d7ccc53abefe6434fa403c35bc70"><code>977d2c3</code></a>
🐛 fix(soft): wait on an empty marker instead of evicting (<a
href="https://redirect.github.com/tox-dev/py-filelock/issues/846">#846</a>)</li>
<li><a
href="https://github.com/tox-dev/filelock/commit/740ff666b62a88496c8d7394e4e6230605e4d62b"><code>740ff66</code></a>
🐛 fix(soft): break stale markers without emptying the lock path (<a
href="https://redirect.github.com/tox-dev/py-filelock/issues/843">#843</a>)</li>
<li><a
href="https://github.com/tox-dev/filelock/commit/86c6d5fb9c23bbcc9f20ab7eda0d625305549b64"><code>86c6d5f</code></a>
🐛 fix(async): honor cancellation and per-thread gates (<a
href="https://redirect.github.com/tox-dev/py-filelock/issues/844">#844</a>)</li>
<li><a
href="https://github.com/tox-dev/filelock/commit/eeceaa846cbe4df72718d94c8371ca1ab8f5b3cc"><code>eeceaa8</code></a>
🐛 fix(soft): keep live holders when owner identity differs (<a
href="https://redirect.github.com/tox-dev/py-filelock/issues/836">#836</a>)</li>
<li>Additional commits viewable in <a
href="https://github.com/tox-dev/py-filelock/compare/3.25.2...4.2.1">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=filelock&package-manager=pip&previous-version=3.25.2&new-version=4.2.1)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/cohere-ai/cohere-compass-sdk/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Add `Permission.ADMIN` for upcoming new index-level management role.

Also, make Permission an open enum, with `UNKNOWN` value, so that future
added roles are less SDK-breaking (like `AssetType`).

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
…247)

# Short Human Summary

A recurring pattern when uploading to Compass is to be able to reliably
upload documents, resume where last stopped in case of errors, retry,
etc. This pattern happened quite often in multiple places that it now
deserves to be put in the SDK for re-usability.

To avoid bloating the SDK with features that not everyone might want, I
decided to put this as an "extension" that has to be specifically
requested, i.e. `pip install cohere-compass-sdk[uploads]`.

# Checklist

- [x] Human description provided.
- [x] PR already reviewed by another AI agent with a fresh context.

---

<!-- ai:opencode -->
**[🤖 Rafid's Bot · opencode · claude-opus-5-5]** Everything below this
line is AI generated.

Part of [CMPS-1361](https://linear.app/cohereai/issue/CMPS-1361).

## Why

Uploading a whole directory reliably takes more than `upload_document`.
It needs:
- file discovery;
- document IDs derived from content, so reruns skip what the index
already has;
- bounded workers that wait for processing;
- pruning of documents the source no longer has;
- saved progress, so a failed job can continue where it stopped.

Without it, every Python caller has to build this machinery itself.
Features like this belong in the SDK as optional extensions.

## What

- **New extension `cohere_compass.ext.uploads`.** Optional, higher-level
features now live under `cohere_compass.ext`, following the
`sqlalchemy.ext` and `sphinx.ext` convention, and the core SDK never
imports from it. Each extension gets its own extra: `pip install
cohere-compass-sdk[uploads]` adds `gcsfs` for `gs://` sources (local
sources need no extra), and `[all]` installs every extension's
dependencies. AGENTS.md states the rule for future extensions.
- **The caller chooses where state lives.** `run_upload_job` takes an
`UploadJobStore`:
- `SqliteUploadJobStore(path)` keeps jobs in a SQLite database, one row
per file, in WAL mode. Saving a file's status took about 0.15 ms whether
the job had 1,000 or 100,000 files. It's the store for large jobs, and
covers the SDK half of
[CMPS-1343](https://linear.app/cohereai/issue/CMPS-1343).
- `FileUploadJobStore(directory)` keeps one JSON file per job, which
people can read and edit. Saving a status rewrites the whole file: about
25 ms at 1,000 files and 250 ms at 10,000, about six times per file on a
fresh upload. Its docs say to use it for up to a few thousand files.
- `InMemoryUploadJobStore()` keeps jobs only for the life of the
process.
- **Progress** goes to an `UploadReporter`, whose methods all do nothing
by default. Terminal UI stays with callers.
- **Jobs carry only what the caller chooses.** `create_upload_job` takes
an optional `job_id`, so a caller can name its jobs and find them with
`store.load`; an optional `api_url`; and a free-form `metadata` mapping
that the extension never reads. Job files with an older top-level
`profile_name` still load, with it moved into `metadata`.
- **README and AGENTS.md** describe the extension. The version goes to
2.24.0.

## Notes

- **Async only.** The uploads extension uses `CompassAsyncClient` and
has no sync twin. That breaks the client sync/async parity convention,
but it doesn't add a second client API.
- **Cancellation propagates.** Cancelling a job saves its progress,
calls `reporter.job_interrupted` and re-raises `CancelledError`, so
callers' `asyncio.timeout` and task cancellation behave normally.
- **Pruning uses bulk `delete_documents`** in batches of
`MAX_BULK_DELETE_DOCUMENT_IDS`, with at most `workers` requests in
flight.
- **`UploadOptions` is easy to build by hand.** Fields have defaults (8
workers, recursive, 300 s timeout, and so on), so only the source, its
type and the index are required. It also accepts a list of patterns, a
`Path` source and a `SourceType` value as a string. `workers` stays
strict, so `True` isn't taken for one worker.
- **Pruning follows the patterns.** With
`include_patterns`/`exclude_patterns`, `prune=True` deletes every
document that isn't one of the filtered files, including documents
uploaded earlier from files the patterns now leave out. The README and
the option's comment say so.
- **Scale.** Pruning keeps every document ID in memory, so it's meant
for indexes of up to tens of thousands of documents.
- **Validation:** the ported tests pass on Python 3.11, 3.12 and 3.15.
Internal callers of the extension ran against Compass staging with this
branch installed:
  - a prune dry run;
- an upload of a 20-PDF corpus that was cancelled partway, then resumed
from the saved job without rescanning the corpus.
…ories' modes (#248)

<!-- ai:opencode -->
**[🤖 Rafid's Bot · opencode · claude-opus-5-5]** Everything below this
line is AI generated.

Follow-up fixes to the uploads extension added in #247.

## Why

- **`SqliteUploadJobStore` changed the mode of directories it didn't
own.** On first use it forced the database's parent directory to `0700`,
even when that directory already existed. A database at
`/var/lib/my-app/uploads.db` (the docstring's own example) locked other
users and processes out of `/var/lib/my-app`.
`SqliteUploadJobStore("uploads.db")` did the same to the working
directory. `/tmp/uploads.db` failed for a non-root user, and for root it
stripped `/tmp`'s world-writable and sticky bits. `FileUploadJobStore`
had the same behaviour for its job directory.
- **Code holding an `UploadJobStore` couldn't close it**, because only
the SQLite store had `close()`, and the docstring example never closed
it.
- **The SQLite tables had no version**, so a later change to their
layout couldn't tell old databases from new ones. The SQLite store also
skipped the saved-job upgrade step that the JSON store runs.

## What

- Both file-backed stores now create a missing state directory with mode
`0700` and leave an existing directory's mode unchanged. Database and
job files are still `0600`.
- `UploadJobStore` gains `close()`, which does nothing by default, and
every store can be used with `async with`. The module docstring example
now uses it.
- `SqliteUploadJobStore` saves its table layout version as SQLite's
`user_version`. A database with no version, as created by 2.24.0, has
the same layout and is upgraded in place to version 1. A database with a
newer version raises `UploadStateError` and is left unchanged.
- The SQLite store runs loaded jobs through the same upgrade step as the
JSON store.
- The README and docstrings say that the SQLite database must be on a
local disk, because SQLite's WAL mode doesn't work on network file
systems such as NFS.
- The version goes to 2.25.0, a minor release because `close()` and
`async with` are new public API.

The full test suite, ruff and pyright pass locally. New tests cover
existing directories keeping their mode, both stores as context
managers, the version check, and the SQLite upgrade path.
…search (#249)

Adds an optional `group_scopes` parameter to the search methods, which
narrows document-level security for a single search to a given set of
Compass groups.

## What

- `SearchInput` and `DirectSearchInput` gain an optional `group_scopes:
list[str] | None` field.
- `CompassClient` and `CompassAsyncClient` accept a `group_scopes`
keyword argument on `search_documents`, `search_chunks` and
`direct_search`, and send it in the request body.
- Each entry is a Compass group name, matched against the values in
documents' `authorized_groups`. The docstrings describe how the server
handles the field:
  - A request carries 1 to 2,000 entries.
- Only the scopes the caller holds are applied. The others are dropped
without an error, and public documents are excluded.
- When the caller holds none of the scopes, the server returns 403,
which the client raises as `CompassAuthError`.
- A scroll opened by `direct_search` with `group_scopes` stays scoped on
later `direct_search_scroll` pages, which must use the same bearer
token.
- The field requires Compass 0.118.0 or later. Older servers ignore it.
- When `group_scopes` is `None`, the default, the field is left out of
the request body, so existing calls send the same request as before. An
empty list is sent as `[]`, and the server rejects it with 400.
- The version goes to 2.26.0, a minor release because the parameter is
new public API.

## Testing

- New tests in `tests/test_compass_client.py` run each of
`search_documents`, `search_chunks` and `direct_search` against both the
sync and async clients. They check that the request body carries
`group_scopes` exactly as given when it is set, including an empty list,
and leaves it out when it is `None`.
- The full test suite, ruff and pyright pass locally.

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: North Code <noreply@cohere.com>
Adds an optional `index_fields` field to `ParseableDocumentConfig`, so
callers of `upload_document`, `upload_document_via_uuid` and
`upload_documents` can choose which content fields Compass embeds for
semantic search.

## What

- `ParseableDocumentConfig.index_fields: list[str] | None`, default
`None`. When set, it replaces the parser's list of embedded fields for
that document, matching `index_fields` on sync document insertion.
- Each entry is stripped of surrounding whitespace and must be
non-empty, the same rule the server applies, so blank entries fail
locally with a `ValidationError` instead of a 400.
- The docstring describes the server's behavior: listed fields missing
from a chunk are skipped, and when none exist the embedded text falls
back to `text` and `meta`.
- Requires Compass 0.118.0 or later (cohere-ai/compass#4071). Older
servers ignore the field. On collections whose uploads fan out to
pipelines, the server honors it once cohere-ai/compass#4072 is released.
- When `index_fields` is `None`, it is left out of the request body, so
existing calls send the same request as before.
- The version goes to 2.27.0, a minor release because the field is new
public API.

## Testing

- New tests in `tests/test_compass_client.py` run against both the sync
and async clients. They check that `upload_document` sends
`index_fields` stripped when it is set and omits it when it is `None`.
They also check that blank entries are rejected.
- The full test suite, ruff and `poetry run pyright` pass locally.

Co-authored-by: North Code <noreply@cohere.com>
… loop (#254)

<!-- ai:opencode -->
**[🤖 Rafid's Bot · opencode · claude-opus-5-5]** Everything below this
line is AI generated.

Fixes [CMPS-1393](https://linear.app/cohereai/issue/CMPS-1393).

## Why

The uploads extension (#247) awaits gcsfs coroutines (`_info`, `_find`,
`_cat_file`, ...) on the caller's event loop, using the `GCSFileSystem`
instance that fsspec caches for the whole process. gcsfs binds that
instance's aiohttp session to the loop of its first request. fsspec's
sync wrappers always run on `fs.loop`, which is fsspec's IO-thread loop.
So whichever side used `gs://` second failed with `got Future attached
to a different loop`: either the uploads code, or every other fsspec
user in the process (pandas, `fsspec.open`, datasets, ...). A second
`asyncio.run` in the same process also failed, with `Event loop is
closed`. This blocks apiary#13126 (Bee's CompassMCPTask), which uploads
and then reads its datasets from GCS in the same process.

## What

Each gcsfs coroutine is now scheduled on `fs.loop`, the same loop
fsspec's sync wrappers use, and its result is awaited with
`asyncio.run_coroutine_threadsafe` + `asyncio.wrap_future`. This is what
`fsspec.asyn.sync` does, except that it doesn't block a thread. The
shared session then stays on a single loop, so the uploads code and
synchronous fsspec users can share the cached instance in either order.

Compared with giving the extension its own per-loop filesystem, nothing
new is created: no second instance, no extra credential loading, no
session lifecycle to manage, and no fsspec cache key that a recycled
loop address could break. Cancelling the caller also cancels the task
running on fsspec's loop.

**Trade-off:** the uploads' GCS I/O now runs on fsspec's single IO loop
and shares its connection pool with other fsspec users in the process.
That should be fine for network-bound async I/O, but upload throughput
now depends on that loop.

The version goes to 2.25.1.

The ticket's repro script, extended with a `read_source_bytes` call and
two more `asyncio.run` calls, now succeeds in both orders against a
public GCS bucket, with nothing on stderr under `-W
error::ResourceWarning`. A new unit test, which fails on `main`, checks
that the coroutines run on `fs.loop` rather than the caller's loop. The
full suite, ruff and pyright pass locally.
…er on client errors (#258)

Related: [CMPS-1352](https://linear.app/cohereai/issue/CMPS-1352)
(server side: cohere-ai/compass#3994, released in Compass v0.119.0).

## Why

Compass v0.119.0 adds `POST /v1/indexes/{index_name}/_count`, which
counts the chunks in an index and the documents they belong to,
optionally per value of one field. The server PR left the SDK methods
for this repo, and asked that they use an HTTP timeout above 60 s and a
single attempt.

## What

### `count()` on `CompassClient` and `CompassAsyncClient`

```python
result = client.count(
    index_name="my-index",
    query={"term": {"content.source_system.keyword": "fda"}},  # optional
    group_by="content.file_type.keyword",                      # optional
    group_size=100,                                            # 1 to 500
    group_scopes=["team-a"],                                   # optional
)
result.chunk_count, result.document_count
for v in result.group_by.values:
    print(v.value, v.chunk_count, v.document_count)
```

- **Response models:** `CountResponse`, `CountGroup`, `CountValue` and
`CountBucket` in `models/search.py`. Grouped values come back as text or
numbers, as the server sends them.
- **One attempt by default:** `max_retries` defaults to 1 rather than
the client's 3, because a retry runs the whole count again while
OpenSearch may still be running the first. Callers can still pass
`max_retries`.
- **Longer timeout by default:** the longer of the client's timeout and
the new `DEFAULT_COMPASS_COUNT_TIMEOUT` (90 s). The client's usual 60 s
would give up just as the server's own 60 s limit answers 504. Callers
can still pass `timeout`.
- **Docstrings** cover the server's answers: 404 when the deployment
hasn't turned counting on (`ENABLE_COUNT`, off by default), 400, 403,
429, 503 and 504.

### `retry_after` on `CompassClientError` and `CompassAuthError`

Every 429 from a count carries `Retry-After: 10`, but the SDK dropped
response headers. `handle_httpx_exceptions()` now reads Retry-After on
any 4xx, as delay-seconds or an HTTP-date, into `retry_after: timedelta
| None`. A date already past is zero; a value that can't be read is
`None`, never an error. Existing `CompassClientError(message, code)`
calls are unchanged, and 429s are still not retried automatically.

```python
except CompassClientError as e:
    if e.code == 429 and e.retry_after is not None:
        time.sleep(e.retry_after.total_seconds())
```

All five clients go through `handle_httpx_exceptions()`, so the parser
and access-control clients get `retry_after` too.

### Fix: `CompassAsyncClient` ignored per-call `timeout`

`CompassAsyncClient._send_request` never passed `timeout` to
`_send_http_request`, so every async method used the client's timeout
whatever the caller passed. The sync client already passed it.
**Behavior change:** async callers who pass `timeout=` now get that
timeout.

### Version

2.27.1 → 2.28.0.

## Testing

- `poetry run pytest -sv`: 512 passed, 89.6% coverage. New tests run
against both the sync and the async client:
- **count:** the request body and parsed response, grouped and
ungrouped; one attempt on 400, 404, 429, 503, 504 and on a timeout;
retries when `max_retries` is passed; the timeout rules (default, a
longer client timeout, an explicit one).
- **retry_after:** delay-seconds, zero, a future and a past HTTP-date,
and `None` for a missing, empty, text, negative, fractional or too-large
value; a 429 isn't retried even with `max_retries=3`; `CompassAuthError`
carries it too.
- `poetry run ruff check --fix . && poetry run ruff format .`: clean.
- `poetry run pyright cohere_compass tests`: 0 errors.

Co-authored-by: North Code <noreply@cohere.com>
## Problem

`_send_http_request` (sync and async clients) decided how to decode a
response from an exact match on `Content-Type`:

- `image/jpeg`, `image/png`, `image/webp`, `audio/*` and `video/*` came
back as bytes.
- Only an exact `text/markdown` came back as str.
- Everything else went through `response.json()`.

So `get_document_asset` raised `JSONDecodeError` on any other file type.
That includes `raw` assets (the original upload, stored with
`ENABLE_RAW_FILE_ASSET=true`), whose content type is the upload's own,
such as `application/pdf` or `text/csv`.

It also raised for Markdown assets served by a real Compass. The asset
endpoint returns `fastapi.Response(content, media_type=content_type)`,
and Starlette appends a charset to `text/*` types, so the header is
`text/markdown; charset=utf-8` and never matched exactly.

## Change

The client now strips parameters from the media type before comparing:

| Media type | Result |
|---|---|
| `application/json`, `*+json`, or no content type | `response.json()`,
or `None` when the body is empty (unchanged) |
| `text/*` | `response.text` (str) |
| anything else | `response.content` (bytes) |

The `get_document_asset` docstrings now describe these return types.
Version bumped to 2.27.2.

JSON API responses are decoded as before. I checked that no Compass API
route returns a `text/*` response; `PlainTextResponse` appears only in
tests.

## Testing

- New parametrized `test_get_document_asset_decodes_by_media_type` runs
against both the sync and async clients. It covers Markdown and CSV with
a charset, `text/plain`, JSON with a charset, `+json`, PDF,
`application/octet-stream`, GIF and MP4.
- `poetry run pytest`: 483 passed, 89.6% coverage. ruff and pyright
pass.

Co-authored-by: North Code <noreply@cohere.com>
# Conflicts:
#	cohere_compass/clients/compass.py
#	cohere_compass/clients/compass_async.py
#	cohere_compass/models/search.py
#	pyproject.toml
@kyleking-cohere
kyleking-cohere requested a review from a team as a code owner November 30, 2026 17:56
@kyleking-cohere
kyleking-cohere requested review from CelineWei-cohere and removed request for a team November 30, 2026 17:56
@cla-assistant

cla-assistant Bot commented Nov 30, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
5 out of 6 committers have signed the CLA.

✅ CalvinLu-cohere
✅ dbaxter-cohere
✅ benrules3
✅ ankush-cohere
✅ jarrah-cohere
❌ kyleking-cohere
You have signed the CLA already but the status is still pending? Let us recheck it.

@cla-assistant

cla-assistant Bot commented Nov 30, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
5 out of 6 committers have signed the CLA.

✅ CalvinLu-cohere
✅ jarrah-cohere
✅ dbaxter-cohere
✅ ankush-cohere
✅ benrules3
❌ kyleking-cohere
You have signed the CLA already but the status is still pending? Let us recheck it.

@kyleking-cohere

Copy link
Copy Markdown
Author

@North-Code review

@kyleking-cohere

Copy link
Copy Markdown
Author

bugbot run

@kyleking-cohere

Copy link
Copy Markdown
Author

Landing note: NCR and Bugbot don't run on this repo (no review from either on #265 to #268, and asking got none). CI is green on dde44b9, including governance-on-off and 596 unit tests. The coordinator reviewed the conflict resolution: permit and group_scopes are both carried on every search, and count takes a permit. license/cla is pending, as on the earlier merges.

@kyleking-cohere
kyleking-cohere merged commit dde44b9 into data-governance Nov 30, 2026
13 of 14 checks passed
@kyleking-cohere
kyleking-cohere deleted the kyle/pro-1122-merge-main-30nov branch November 30, 2026 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants