From f92cea06b022795c6655b06f5ea79b445bccc6a0 Mon Sep 17 00:00:00 2001 From: Felipe Gutierrez Date: Wed, 25 Nov 2026 14:51:00 -0500 Subject: [PATCH] Align consumer AGENTS.md to canonical; release cockroachdb 0.1.4 Align the Python consumer AGENTS.md with Greg's canonical Spring consumer guide (Spring PR #40): - Add "Learn CockroachDB fundamentals" section linking the official CRDB docs via their .md variants + docs.cockroachlabs.com/llms.txt, translated to the Python API (@regional_by_row/@global_table, @follower_read, @changefeed_handler). Existing Python helper/anti-pattern content kept. - Publish the guide to the PEP 503 Pages site at /agents/AGENTS.md and emit llms.txt (new pages.yml step). README now notes the guide lives in two places: the wheel (cockroachdb/AGENTS.md) and the site. - Bump base package cockroachdb 0.1.3 -> 0.1.4; bump ideas-board example pin to match the single-version feed. Bake path unchanged (sdist force-include -> cockroachdb/AGENTS.md); verify-in-artifact test still green. --- .github/workflows/pages.yml | 16 +++++++++ README.md | 2 +- docs/agents/AGENTS.md | 47 +++++++++++++++++++++++++++ examples/ideas-board/README.md | 4 +-- examples/ideas-board/requirements.txt | 2 +- packages/cockroachdb/pyproject.toml | 2 +- uv.lock | 12 +++---- 7 files changed, 74 insertions(+), 11 deletions(-) diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index 32d017a..a4998f4 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -48,6 +48,22 @@ jobs: - name: Assemble Pages site (landing + PEP 503 index) run: python3 scripts/build_pages.py + - name: Publish consumer AGENTS.md + llms.txt + run: | + set -euo pipefail + mkdir -p _site/agents + cp docs/agents/AGENTS.md _site/agents/AGENTS.md + cat > _site/llms.txt <<'EOF' + # CockroachDB Python Library + + Consumer guide for coding agents working in an app that depends on the + `cockroachdb` packages (which helpers to use, what not to hand-roll): + https://cockroachlabs.github.io/cockroachdb-python-library/agents/AGENTS.md + + The same guide ships inside the installed base package at `cockroachdb/AGENTS.md`. + For CockroachDB database fundamentals, see https://docs.cockroachlabs.com/llms.txt + EOF + - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v4 with: diff --git a/README.md b/README.md index 9e42c29..ecb51be 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A production-grade Python library for [CockroachDB](https://www.cockroachlabs.com/) that provides automatic transaction retry handling, multi-region support, follower reads, CDC webhook handlers, vector search, and RAG pipelines. Part of the CockroachDB language-specific library family alongside the [Java Spring Boot Starter](https://github.com/cockroachlabs/cockroachdb-java-library), [.NET Library](https://github.com/cockroachlabs/cockroachdb-dotnet-library), and [Go Library](https://github.com/cockroachlabs/cockroachdb-go-library). -> **Using an AI coding agent?** A consumer guide for agents working in your app ships inside the installed package at `cockroachdb/AGENTS.md` (source: [`docs/agents/AGENTS.md`](docs/agents/AGENTS.md)) — it tells the agent which helpers to use and what not to hand-roll. +> **Using an AI coding agent?** A consumer guide for agents working in your app lives in **two places**: inside the installed package at `cockroachdb/AGENTS.md` (shipped in the wheel) and on the Pages site at [`/agents/AGENTS.md`](https://cockroachlabs.github.io/cockroachdb-python-library/agents/AGENTS.md) (source: [`docs/agents/AGENTS.md`](docs/agents/AGENTS.md)) — it tells the agent which helpers to use and what not to hand-roll. ## Architecture diff --git a/docs/agents/AGENTS.md b/docs/agents/AGENTS.md index cd991ab..8943898 100644 --- a/docs/agents/AGENTS.md +++ b/docs/agents/AGENTS.md @@ -52,3 +52,50 @@ Everything is `CockroachDBConfig` (Pydantic), overridable via `CRDB_`-prefixed e Use `cockroachdb-testing`: `CockroachDBFixture` (Testcontainers-backed real CockroachDB) and `RetrySimulator` (injects `40001` failures to prove retry works). Don't mock the driver. + +## Learn CockroachDB fundamentals + +The library handles the Python side; these CockroachDB docs explain the database underneath. The +links below go to the Markdown version of each page, which is easier for an agent to read; drop the +`.md` for the HTML page. Every docs page has one, and +indexes the whole documentation site. + +**Start here** + +- [Developer Basics](https://docs.cockroachlabs.com/docs/stable/developer-basics.md): what's different about building on CockroachDB. +- [PostgreSQL Compatibility](https://docs.cockroachlabs.com/docs/stable/postgresql-compatibility.md): CockroachDB speaks the PostgreSQL wire protocol (use a PostgreSQL driver — `psycopg`, `asyncpg`, or SQLAlchemy), with some differences. +- [Connection Pooling](https://docs.cockroachlabs.com/docs/stable/connection-pooling.md): sizing a client-side pool. +- [Common Errors and Solutions](https://docs.cockroachlabs.com/docs/stable/common-errors.md) + +**Transactions and contention** + +- [Transactions](https://docs.cockroachlabs.com/docs/stable/transactions.md): SERIALIZABLE by default, and why clients see retry errors. +- [Transaction Retry Error Reference](https://docs.cockroachlabs.com/docs/stable/transaction-retry-error-reference.md): what each `40001` (`RETRY_SERIALIZABLE`, `RETRY_WRITE_TOO_OLD`, ...) means and how to make it rarer. The library retries them; this tells you why they happen. +- [Reduce transaction contention](https://docs.cockroachlabs.com/docs/stable/performance-best-practices-overview.md#reduce-transaction-contention): the checklist. Keep transactions small, limit the rows they touch, use `SELECT ... FOR UPDATE` for read-then-write, `UPSERT` whole rows, use historical reads where staleness is fine. +- [Understand Hotspots](https://docs.cockroachlabs.com/docs/stable/understand-hotspots.md): ranges that take far more traffic than others, and how to spread it. +- [Performance Tuning Recipes](https://docs.cockroachlabs.com/docs/stable/performance-recipes.md): symptoms and fixes, contention included. +- [Monitor and Analyze Transaction Contention](https://docs.cockroachlabs.com/docs/stable/monitor-and-analyze-transaction-contention.md) +- [`SELECT FOR UPDATE`](https://docs.cockroachlabs.com/docs/stable/select-for-update.md) +- [Read Committed Transactions](https://docs.cockroachlabs.com/docs/stable/read-committed.md): an alternative isolation level, with trade-offs. Don't switch to it just to avoid retries — at READ COMMITTED `40001` never surfaces and the library's retry silently no-ops. + +**Schema design** + +- [Database Schemas](https://docs.cockroachlabs.com/docs/stable/schema-design-overview.md): how to design and change schemas, including why to change them with a migration tool rather than through the ORM. +- [Unique ID best practices](https://docs.cockroachlabs.com/docs/stable/performance-best-practices-overview.md#unique-id-best-practices): prefer `UUID` keys (`gen_random_uuid()`) over sequences or auto-increment, which create hotspots. +- [`UUID`](https://docs.cockroachlabs.com/docs/stable/uuid.md) and [Hash-sharded Indexes](https://docs.cockroachlabs.com/docs/stable/hash-sharded-indexes.md), for when an index must be on a sequential column. +- [Online Schema Changes](https://docs.cockroachlabs.com/docs/stable/online-schema-changes.md): schema changes run in the background; what that means for migrations. + +**Multi-region** + +- [Multi-Region Capabilities Overview](https://docs.cockroachlabs.com/docs/stable/multiregion-overview.md) +- [Table Localities](https://docs.cockroachlabs.com/docs/stable/table-localities.md): `REGIONAL BY TABLE`, `REGIONAL BY ROW` and `GLOBAL`, which `@regional_by_row` and `@global_table` map to. +- [How to Choose a Multi-Region Configuration](https://docs.cockroachlabs.com/docs/stable/choosing-a-multi-region-configuration.md) +- [Follower Reads](https://docs.cockroachlabs.com/docs/stable/follower-reads.md) and [`AS OF SYSTEM TIME`](https://docs.cockroachlabs.com/docs/stable/as-of-system-time.md), behind `@follower_read`. + +**Change data capture** + +- [`CREATE CHANGEFEED`](https://docs.cockroachlabs.com/docs/stable/create-changefeed.md) and [Changefeed Sinks](https://docs.cockroachlabs.com/docs/stable/changefeed-sinks.md) (the webhook sink is what `@changefeed_handler` receives). + +**Vector search** + +- [`VECTOR`](https://docs.cockroachlabs.com/docs/stable/vector.md) and [Vector Indexes](https://docs.cockroachlabs.com/docs/stable/vector-indexes.md) diff --git a/examples/ideas-board/README.md b/examples/ideas-board/README.md index 043c5eb..215dc82 100644 --- a/examples/ideas-board/README.md +++ b/examples/ideas-board/README.md @@ -46,12 +46,12 @@ source .venv/bin/activate pip install -r requirements.txt ``` -`requirements.txt` pins the **published** `cockroachdb==0.1.3` (plus +`requirements.txt` pins the **published** `cockroachdb==0.1.4` (plus `cockroachdb-testing==0.1.1`) and carries the `--extra-index-url` line for the feed. A single-package install looks like: ```bash -pip install 'cockroachdb==0.1.3' \ +pip install 'cockroachdb==0.1.4' \ --extra-index-url https://cockroachlabs.github.io/cockroachdb-python-library/simple/ ``` diff --git a/examples/ideas-board/requirements.txt b/examples/ideas-board/requirements.txt index 37763e7..2fd40f2 100644 --- a/examples/ideas-board/requirements.txt +++ b/examples/ideas-board/requirements.txt @@ -4,7 +4,7 @@ # anonymous PEP 503 feed, NOT public PyPI. --extra-index-url https://cockroachlabs.github.io/cockroachdb-python-library/simple/ -cockroachdb==0.1.3 +cockroachdb==0.1.4 cockroachdb-core==0.3.0 # metrics (RetryEngine) + follower-read/region context cockroachdb-sqlalchemy==0.3.0 # multi-region schema check (verify_multiregion_schema + ORM mixins); pulls sqlalchemy>=2.0 cockroachdb-cdc==0.2.0 # changefeed handlers + webhook payload parsing diff --git a/packages/cockroachdb/pyproject.toml b/packages/cockroachdb/pyproject.toml index c908b48..1cf7a27 100644 --- a/packages/cockroachdb/pyproject.toml +++ b/packages/cockroachdb/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "cockroachdb" -version = "0.1.3" +version = "0.1.4" description = "CockroachDB Python Library — base decorators, types, and configuration" readme = "README.md" requires-python = ">=3.11" diff --git a/uv.lock b/uv.lock index 9bb3020..c9b5d4d 100644 --- a/uv.lock +++ b/uv.lock @@ -323,7 +323,7 @@ wheels = [ [[package]] name = "cockroachdb" -version = "0.1.1" +version = "0.1.4" source = { editable = "packages/cockroachdb" } dependencies = [ { name = "pydantic" }, @@ -347,7 +347,7 @@ provides-extras = ["dev"] [[package]] name = "cockroachdb-ai" -version = "0.1.1" +version = "0.2.0" source = { editable = "packages/cockroachdb-ai" } dependencies = [ { name = "cockroachdb" }, @@ -385,7 +385,7 @@ provides-extras = ["openai", "local", "dev"] [[package]] name = "cockroachdb-cdc" -version = "0.1.1" +version = "0.2.0" source = { editable = "packages/cockroachdb-cdc" } dependencies = [ { name = "cockroachdb" }, @@ -461,7 +461,7 @@ provides-extras = ["dev"] [[package]] name = "cockroachdb-core" -version = "0.1.1" +version = "0.3.0" source = { editable = "packages/cockroachdb-core" } dependencies = [ { name = "cockroachdb" }, @@ -497,7 +497,7 @@ provides-extras = ["metrics", "otel", "dev"] [[package]] name = "cockroachdb-django" -version = "0.1.1" +version = "0.3.0" source = { editable = "packages/cockroachdb-django" } dependencies = [ { name = "cockroachdb" }, @@ -549,7 +549,7 @@ requires-dist = [ [[package]] name = "cockroachdb-sqlalchemy" -version = "0.1.1" +version = "0.3.0" source = { editable = "packages/cockroachdb-sqlalchemy" } dependencies = [ { name = "cockroachdb" },