# pgai - Doramagic AI Context Pack

> 定位：安装前体验与判断资产。它帮助宿主 AI 有一个好的开始，但不代表已经安装、执行或验证目标项目。

## 充分原则

- **充分原则，不是压缩原则**：AI Context Pack 应该充分到让宿主 AI 在开工前理解项目价值、能力边界、使用入口、风险和证据来源；它可以分层组织，但不以最短摘要为目标。
- **压缩策略**：只压缩噪声和重复内容，不压缩会影响判断和开工质量的上下文。

## 给宿主 AI 的使用方式

你正在读取 Doramagic 为 pgai 编译的 AI Context Pack。请把它当作开工前上下文：帮助用户理解适合谁、能做什么、如何开始、哪些必须安装后验证、风险在哪里。不要声称你已经安装、运行或执行了目标项目。

## Claim 消费规则

- **事实来源**：Repo Evidence + Claim/Evidence Graph；Human Wiki 只提供显著性、术语和叙事结构。
- **事实最低状态**：`supported`
- `supported`：可以作为项目事实使用，但回答中必须引用 claim_id 和证据路径。
- `weak`：只能作为低置信度线索，必须要求用户继续核实。
- `inferred`：只能用于风险提示或待确认问题，不能包装成项目事实。
- `unverified`：不得作为事实使用，应明确说证据不足。
- `contradicted`：必须展示冲突来源，不得替用户强行选择一个版本。

## 它最适合谁

- **正在使用 Claude/Codex/Cursor/Gemini 等宿主 AI 的开发者**：README 或插件配置提到多个宿主 AI。 证据：`README.md` Claim：`clm_0002` supported 0.86

## 它能做什么

- **命令行启动或安装流程**（需要安装后验证）：项目文档中存在可执行命令，真实使用需要在本地或宿主环境中运行这些命令。 证据：`README.md` Claim：`clm_0001` supported 0.86

## 怎么开始

- `pip install pgai` 证据：`README.md` Claim：`clm_0003` supported 0.86, `clm_0004` supported 0.86, `clm_0005` supported 0.86
- `pip install "pgai[vectorizer-worker]"` 证据：`README.md` Claim：`clm_0004` supported 0.86
- `pip install "pgai[semantic-catalog]"` 证据：`README.md` Claim：`clm_0005` supported 0.86
- `curl -O https://raw.githubusercontent.com/timescale/pgai/main/examples/quickstart/main.py` 证据：`README.md` Claim：`clm_0006` supported 0.86
- `curl -O https://raw.githubusercontent.com/timescale/pgai/main/examples/quickstart/requirements.txt` 证据：`README.md` Claim：`clm_0007` supported 0.86
- `pip install -r requirements.txt` 证据：`README.md` Claim：`clm_0008` supported 0.86

## 继续前判断卡

- **当前建议**：需要管理员/安全审批
- **为什么**：继续前可能涉及密钥、账号、外部服务或敏感上下文，建议先经过管理员或安全审批。

### 30 秒判断

- **现在怎么做**：需要管理员/安全审批
- **最小安全下一步**：先跑 Prompt Preview；若涉及凭证或企业环境，先审批再试装
- **先别相信**：角色质量和任务匹配不能直接相信。
- **继续会触碰**：角色选择偏差、命令执行、本地环境或项目文件

### 现在可以相信

- **适合人群线索：正在使用 Claude/Codex/Cursor/Gemini 等宿主 AI 的开发者**（supported）：有 supported claim 或项目证据支撑，但仍不等于真实安装效果。 证据：`README.md` Claim：`clm_0002` supported 0.86
- **能力存在：命令行启动或安装流程**（supported）：可以相信项目包含这类能力线索；是否适合你的具体任务仍要试用或安装后验证。 证据：`README.md` Claim：`clm_0001` supported 0.86
- **存在 Quick Start / 安装命令线索**（supported）：可以相信项目文档出现过启动或安装入口；不要因此直接在主力环境运行。 证据：`README.md` Claim：`clm_0003` supported 0.86, `clm_0004` supported 0.86, `clm_0005` supported 0.86

### 现在还不能相信

- **角色质量和任务匹配不能直接相信。**（unverified）：角色库证明有很多角色，不证明每个角色都适合你的具体任务，也不证明角色能产生高质量结果。
- **不能把角色文案当成真实执行能力。**（unverified）：安装前只能判断角色描述和任务画像是否匹配，不能证明它能在宿主 AI 里完成任务。
- **真实输出质量不能在安装前相信。**（unverified）：Prompt Preview 只能展示引导方式，不能证明真实项目中的结果质量。
- **宿主 AI 版本兼容性不能在安装前相信。**（unverified）：Claude、Cursor、Codex、Gemini 等宿主加载规则和版本差异必须在真实环境验证。
- **不会污染现有宿主 AI 行为，不能直接相信。**（inferred）：Skill、plugin、AGENTS/CLAUDE/GEMINI 指令可能改变宿主 AI 的默认行为。
- **可安全回滚不能默认相信。**（unverified）：除非项目明确提供卸载和恢复说明，否则必须先在隔离环境验证。
- **真实安装后是否与用户当前宿主 AI 版本兼容？**（unverified）：兼容性只能通过实际宿主环境验证。
- **项目输出质量是否满足用户具体任务？**（unverified）：安装前预览只能展示流程和边界，不能替代真实评测。

### 继续会触碰什么

- **角色选择偏差**：用户对任务应该由哪个专家角色处理的判断。 原因：选错角色会让 AI 从错误专业视角回答，浪费时间或误导决策。
- **命令执行**：包管理器、网络下载、本地插件目录、项目配置或用户主目录。 原因：运行第一条命令就可能产生环境改动；必须先判断是否值得跑。 证据：`README.md`
- **本地环境或项目文件**：安装结果、插件缓存、项目配置或本地依赖目录。 原因：安装前无法证明写入范围和回滚方式，需要隔离验证。 证据：`README.md`
- **环境变量 / API Key**：项目入口文档明确出现 API key、token、secret 或账号凭证配置。 原因：如果真实安装需要凭证，应先使用测试凭证并经过权限/合规判断。 证据：`README.md`, `docs/semantic_catalog/cli.md`, `docs/semantic_catalog/quickstart-demo-data.md`, `docs/semantic_catalog/quickstart-your-data.md` 等
- **宿主 AI 上下文**：AI Context Pack、Prompt Preview、Skill 路由、风险规则和项目事实。 原因：导入上下文会影响宿主 AI 后续判断，必须避免把未验证项包装成事实。

### 最小安全下一步

- **先跑 Prompt Preview**：先用交互式试用验证任务画像和角色匹配，不要先导入整套角色库。（适用：任何项目都适用，尤其是输出质量未知时。）
- **只在隔离目录或测试账号试装**：避免安装命令污染主力宿主 AI、真实项目或用户主目录。（适用：存在命令执行、插件配置或本地写入线索时。）
- **不要使用真实生产凭证**：环境变量/API key 一旦进入宿主或工具链，可能产生账号和合规风险。（适用：出现 API、TOKEN、KEY、SECRET 等环境线索时。）
- **安装后只验证一个最小任务**：先验证加载、兼容、输出质量和回滚，再决定是否深用。（适用：准备从试用进入真实工作流时。）

### 退出方式

- **保留安装前状态**：记录原始宿主配置和项目状态，后续才能判断是否可恢复。
- **保留原始角色选择记录**：如果输出偏题，可以回到任务画像阶段重新选择角色，而不是继续沿着错误角色推进。
- **记录安装命令和写入路径**：没有明确卸载说明时，至少要知道哪些目录或配置需要手动清理。
- **准备撤销测试 API key 或 token**：测试凭证泄露或误用时，可以快速止损。
- **如果没有回滚路径，不进入主力环境**：不可回滚是继续前阻断项，不应靠信任或运气继续。

## 哪些只能预览

- 解释项目适合谁和能做什么
- 基于项目文档演示典型对话流程
- 帮助用户判断是否值得安装或继续研究

## 哪些必须安装后验证

- 真实安装 Skill、插件或 CLI
- 执行脚本、修改本地文件或访问外部服务
- 验证真实输出质量、性能和兼容性

## 边界与风险判断卡

- **把安装前预览误认为真实运行**：用户可能高估项目已经完成的配置、权限和兼容性验证。 处理方式：明确区分 prompt_preview_can_do 与 runtime_required。 Claim：`clm_0009` inferred 0.45
- **命令执行会修改本地环境**：安装命令可能写入用户主目录、宿主插件目录或项目配置。 处理方式：先在隔离环境或测试账号中运行。 证据：`README.md` Claim：`clm_0010` supported 0.86
- **待确认**：真实安装后是否与用户当前宿主 AI 版本兼容？。原因：兼容性只能通过实际宿主环境验证。
- **待确认**：项目输出质量是否满足用户具体任务？。原因：安装前预览只能展示流程和边界，不能替代真实评测。
- **待确认**：安装命令是否需要网络、权限或全局写入？。原因：这影响企业环境和个人环境的安装风险。

## 开工前工作上下文

### 加载顺序

- 先读取 how_to_use.host_ai_instruction，建立安装前判断资产的边界。
- 读取 claim_graph_summary，确认事实来自 Claim/Evidence Graph，而不是 Human Wiki 叙事。
- 再读取 intended_users、capabilities 和 quick_start_candidates，判断用户是否匹配。
- 需要执行具体任务时，优先查 role_skill_index，再查 evidence_index。
- 遇到真实安装、文件修改、网络访问、性能或兼容性问题时，转入 risk_card 和 boundaries.runtime_required。

### 任务路由

- **命令行启动或安装流程**：先说明这是安装后验证能力，再给出安装前检查清单。 边界：必须真实安装或运行后验证。 证据：`README.md` Claim：`clm_0001` supported 0.86

### 上下文规模

- 文件总数：495
- 重要文件覆盖：40/495
- 证据索引条目：63
- 角色 / Skill 条目：44

### 证据不足时的处理

- **missing_evidence**：说明证据不足，要求用户提供目标文件、README 段落或安装后验证记录；不要补全事实。
- **out_of_scope_request**：说明该任务超出当前 AI Context Pack 证据范围，并建议用户先查看 Human Manual 或真实安装后验证。
- **runtime_request**：给出安装前检查清单和命令来源，但不要替用户执行命令或声称已执行。
- **source_conflict**：同时展示冲突来源，标记为待核实，不要强行选择一个版本。

## Prompt Recipes

### 适配判断

- 目标：判断这个项目是否适合用户当前任务。
- 预期输出：适配结论、关键理由、证据引用、安装前可预览内容、必须安装后验证内容、下一步建议。

```text
请基于 pgai 的 AI Context Pack，先问我 3 个必要问题，然后判断它是否适合我的任务。回答必须包含：适合谁、能做什么、不能做什么、是否值得安装、证据来自哪里。所有项目事实必须引用 evidence_refs、source_paths 或 claim_id。
```

### 安装前体验

- 目标：让用户在安装前感受核心工作流，同时避免把预览包装成真实能力或营销承诺。
- 预期输出：一段带边界标签的体验剧本、安装后验证清单和谨慎建议；不含真实运行承诺或强营销表述。

```text
请把 pgai 当作安装前体验资产，而不是已安装工具或真实运行环境。

请严格输出四段：
1. 先问我 3 个必要问题。
2. 给出一段“体验剧本”：用 [安装前可预览]、[必须安装后验证]、[证据不足] 三种标签展示它可能如何引导工作流。
3. 给出安装后验证清单：列出哪些能力只有真实安装、真实宿主加载、真实项目运行后才能确认。
4. 给出谨慎建议：只能说“值得继续研究/试装”“先补充信息后再判断”或“不建议继续”，不得替项目背书。

硬性边界：
- 不要声称已经安装、运行、执行测试、修改文件或产生真实结果。
- 不要写“自动适配”“确保通过”“完美适配”“强烈建议安装”等承诺性表达。
- 如果描述安装后的工作方式，必须使用“如果安装成功且宿主正确加载 Skill，它可能会……”这种条件句。
- 体验剧本只能写成“示例台词/假设流程”：使用“可能会询问/可能会建议/可能会展示”，不要写“已写入、已生成、已通过、正在运行、正在生成”。
- Prompt Preview 不负责给安装命令；如用户准备试装，只能提示先阅读 Quick Start 和 Risk Card，并在隔离环境验证。
- 所有项目事实必须来自 supported claim、evidence_refs 或 source_paths；inferred/unverified 只能作风险或待确认项。

```

### 角色 / Skill 选择

- 目标：从项目里的角色或 Skill 中挑选最匹配的资产。
- 预期输出：候选角色或 Skill 列表，每项包含适用场景、证据路径、风险边界和是否需要安装后验证。

```text
请读取 role_skill_index，根据我的目标任务推荐 3-5 个最相关的角色或 Skill。每个推荐都要说明适用场景、可能输出、风险边界和 evidence_refs。
```

### 风险预检

- 目标：安装或引入前识别环境、权限、规则冲突和质量风险。
- 预期输出：环境、权限、依赖、许可、宿主冲突、质量风险和未知项的检查清单。

```text
请基于 risk_card、boundaries 和 quick_start_candidates，给我一份安装前风险预检清单。不要替我执行命令，只说明我应该检查什么、为什么检查、失败会有什么影响。
```

### 宿主 AI 开工指令

- 目标：把项目上下文转成一次对话开始前的宿主 AI 指令。
- 预期输出：一段边界明确、证据引用明确、适合复制给宿主 AI 的开工前指令。

```text
请基于 pgai 的 AI Context Pack，生成一段我可以粘贴给宿主 AI 的开工前指令。这段指令必须遵守 not_runtime=true，不能声称项目已经安装、运行或产生真实结果。
```

## 角色 / Skill 索引

- 共索引 44 个角色 / Skill / 项目文档条目。

- **pgai documentation**（project_doc）：A Python library that turns PostgreSQL into the retrieval engine behind robust, production-ready RAG and Agentic applications. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/README.md`
- **Semantic Catalog**（project_doc）：Text-to-SQL is a natural language processing technology that converts questions made in human language into SQL queries that you execute in relational databases such as PostgreSQL. Text-to-SQL is a tool that enables non-technical users to interact with data and database systems using everyday language in the place of complex SQL syntax. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/semantic_catalog/README.md`
- **pgai documentation**（project_doc）：Supercharge your PostgreSQL database with AI capabilities. Supports: 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/extension/docs/README.md`
- **install**（project_doc）：Power your RAG and Agentic applications with PostgreSQL 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`README.md`
- **Discord Bot**（project_doc）：A minimal discord bot that answers questions based on pgai's documentation via RAG. Built with python, py-cord, sqlalchemy and pgai. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/discord_bot/README.md`
- **Tutorial: Generating document embeddings with PGAI**（project_doc）：Tutorial: Generating document embeddings with PGAI 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/embeddings_from_documents/README.md`
- **Embedding Models Evaluation using pgai Vectorizer and LiteLLM**（project_doc）：Embedding Models Evaluation using pgai Vectorizer and LiteLLM 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/evaluations/litellm_vectorizer/README.md`
- **Readme**（project_doc）：Evaluating Embedding Models: OpenAI vs. Nomic vs. BGE vs. OpenAI Large Author: Jacky Liang 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/evaluations/ollama_vectorizer/README.md`
- **Readme**（project_doc）：Domain-specific vs. General-purpose Embedding Model Evaluation Author: Jacky Liang 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/evaluations/voyage_vectorizer/README.md`
- **Usage**（project_doc）：This directory contains a simple fastAPI Application with psycopg.py that uses pgai Vectorizer to perform semantic search and RAG. The app will ingest some wikipedia articles, create vector embeddings for them, and allow you to perform semantic search and RAG. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/simple_fastapi_app/README.md`
- **Text-to-SQL Demo**（project_doc）：The text-to-sql feature of pgai allows users to ask a natural language question and have an LLM generate a SQL statement to answer the question. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`examples/text_to_sql/README.md`
- **Idempotent SQL Files**（project_doc）：This directory contains SQL files which are idempotent. Any code in these scripts will be executed on EVERY install and/or upgrade. Therefore, it must be safe to re run multiple times. A good rule of thumb is that CREATE OR REPLACE statements are safe in these files. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/extension/sql/idempotent/README.md`
- **Incremental SQL Files**（project_doc）：This directory contains SQL files which are incremental. Any code in these scripts will be executed on EXACTLY once regardless of install/upgrade path. These are typically referred to as database migrations. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/extension/sql/incremental/README.md`
- **notes on the changes**（project_doc）：- vectorizer job - leaving ai.execute vectorizer in extension - ai. vectorizer job which calls ai.execute vectorizer is moved to dbapp 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/pgai/db/README.md`
- **dataclasses generation for CreateVectorizerParams**（project_doc）：dataclasses generation for CreateVectorizerParams This module contains a script to generate dataclasses as params for the CreateVectorizer class. If the interface for the extension is changed, running this script via uv run generate should update the dataclasses in configuration.py and vectorizer params.py without needing to manually update them. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/pgai/pgai/vectorizer/generate/README.md`
- **Vectorizer Load Test**（project_doc）：This directory contains scripts to help with load testing the vectorizer. The scripts create a table named wiki with approximately 1.5M rows to be vectorized. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`scripts/vectorizer-load-test/README.md`
- **pgai Vectorizer API reference**（project_doc）：This page provides an API reference for Vectorizer functions. For an overview of Vectorizer and how it works, see the Vectorizer Guide /docs/vectorizer/overview.md . 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/vectorizer/api-reference.md`
- **Automate AI embedding with pgai Vectorizer**（project_doc）：Automate AI embedding with pgai Vectorizer 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/vectorizer/overview.md`
- **Contributing to pgai**（project_doc）：Thank you for your interest in contributing to the Timescale pgai https://github.com/timescale/pgai project! This guide outlines the process for reporting issues, proposing features, and submitting pull requests. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`CONTRIBUTING.md`
- **Semantic Catalog CLI Reference**（project_doc）：The pgai semantic catalog feature provides a comprehensive command-line interface for managing semantic catalogs that enable natural language to SQL functionality. This document provides detailed information about each CLI command, their usage, and their purpose in the text-to-SQL workflow. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/semantic_catalog/cli.md`
- **More Questions to Try**（project_doc）：ID Complexity Question ---- -----------: ---------- 1 easy What is the total number of aircraft in the fleet? 2 easy How many international airports are in the database? 3 easy What is the average flight duration for all flights? 4 easy Which airports are located in Tokyo? 5 easy What is the maximum range of any aircraft in the fleet? 6 easy Which aircraft model has the highest velocity? 7 easy List all flights depa… 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/semantic_catalog/more-questions.md`
- **Quickstart with demo data**（project_doc）：We are going to use an open source postgres database named "postgres air" to demonstrate SQL generation. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/semantic_catalog/quickstart-demo-data.md`
- **Quickstart with your data**（project_doc）：This quickstart will help you get up and running with the semantic catalog on your own database. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/semantic_catalog/quickstart-your-data.md`
- **Chunk text with SQL functions**（project_doc）：The ai.chunk text and ai.chunk text recursively functions allow you to split text into smaller chunks. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/utils/chunking.md`
- **Adding a Vectorizer embedding integration**（project_doc）：Adding a Vectorizer embedding integration 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/vectorizer/adding-embedding-integration.md`
- **Alembic integration**（project_doc）：Alembic is a database migration tool that allows you to manage your database schema. This document describes how to use Alembic to manage your vectorizer definitions, since those should be considered part of your database schema. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/vectorizer/alembic-integration.md`
- **Document embeddings in pgai**（project_doc）：This is a comprehensive walkthrough of how embedding generation for documents work in pgai. If you want to get started quickly check out the runnable example /examples/embeddings from documents . 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/vectorizer/document-embeddings.md`
- **Migrating from the extension to the python library**（project_doc）：Previous versions of pgai vectorizer used an extension to provide the vectorizer functionality. We have removed the need for the extension and put the vectorizer code into the pgai python library. This change allows the vectorizer to be used on more PostgreSQL cloud providers AWS RDS, Supabase, etc. and simplifies the installation and upgrade process. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/vectorizer/migrating-from-extension.md`
- **Overview**（project_doc）：This document describes how to create and run vectorizers from Python. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/vectorizer/python-integration.md`
- **Vectorizer quick start with Ollama**（project_doc）：Go to our vectorizer-quickstart here /docs/vectorizer/quick-start.md to start with pgai and ollama. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/vectorizer/quick-start-ollama.md`
- **Pgai vectorizer S3 integration guide**（project_doc）：Pgai vectorizer S3 integration guide 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/vectorizer/s3-documents.md`
- **SQLAlchemy Integration with pgai Vectorizer**（project_doc）：SQLAlchemy Integration with pgai Vectorizer 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`docs/vectorizer/sqlalchemy-integration.md`
- **Install pgai with Docker**（project_doc）：To run pgai, you need to run two containers: 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/extension/docs/install/docker.md`
- **Delayed embed**（project_doc）：You may decide to combine pgai with Timescaledb Background Actions tsdb actions . and you can also use the pgai extension to run background actions. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/extension/docs/model_calling/delayed_embed.md`
- **Use pgai with Ollama**（project_doc）：- Configure pgai for Ollama configure-pgai-for-ollama - Add AI functionality to your database usage 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/extension/docs/model_calling/ollama.md`
- **Privileges**（project_doc）：The ai.grant ai usage function is an important security and access control tool in the pgai extension. Its primary purpose is to grant the necessary permissions for a specified user or role to use the pgai functionality effectively and safely. This function simplifies the process of setting up appropriate access rights, ensuring that users can interact with the AI features without compromising database security. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/extension/docs/security/privileges.md`
- **Load dataset from Hugging Face**（project_doc）：The ai.load dataset function allows you to load datasets from Hugging Face's datasets library directly into your PostgreSQL database. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/extension/docs/utils/load_dataset_from_huggingface.md`
- **Contributing to pgai**（project_doc）：Welcome to the pgai project! This guide will help you get started with contributing to pgai, a project that brings embedding and generation AI models closer to your PostgreSQL database. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`DEVELOPMENT.md`
- **Security policy**（project_doc）：We aim to keep pgai safe for everyone. Publicly disclosing security bugs in a public forum can put everyone in the community at risk. Therefore, we ask that you use the following instructions to report security vulnerabilities. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`SECURITY.md`
- **Working on the pgai extension**（project_doc）：- pgai extension development prerequisites pgai-extension-development-prerequisites - The pgai extension development workflow the-pgai-extension-development-workflow - Controlling pgai extension tests controlling-pgai-extension-tests - The pgai extension architecture the-pgai-extension-architecture 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/extension/DEVELOPMENT.md`
- **Pgai extension release notes**（project_doc）：Use lockfile when installing prior versions when running the install-all command. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/extension/RELEASE_NOTES.md`
- **Changelog**（project_doc）：0.12.1 https://github.com/timescale/pgai/compare/pgai-v0.12.0...pgai-v0.12.1 2025-10-13 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/pgai/CHANGELOG.md`
- **Pgai library release notes**（project_doc）：This is the first release of the Python pgai library, including the Vectorizer worker. When you have defined vectorizers /docs/vectorizer/overview.md define-a-vectorizer on a self-hosted Postgres installation, you run the Vectorizer worker /docs/vectorizer/worker.md to asynchronously processes them. 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/pgai/RELEASE_NOTES.md`
- **This is a test**（project_doc）： 激活提示：当用户需要理解项目结构、安装方式或边界时参考。 证据：`projects/pgai/tests/vectorizer/cli/documents/test.md`

## 证据索引

- 共索引 63 条证据。

- **pgai documentation**（documentation）：A Python library that turns PostgreSQL into the retrieval engine behind robust, production-ready RAG and Agentic applications. 证据：`docs/README.md`
- **Semantic Catalog**（documentation）：Text-to-SQL is a natural language processing technology that converts questions made in human language into SQL queries that you execute in relational databases such as PostgreSQL. Text-to-SQL is a tool that enables non-technical users to interact with data and database systems using everyday language in the place of complex SQL syntax. 证据：`docs/semantic_catalog/README.md`
- **pgai documentation**（documentation）：Supercharge your PostgreSQL database with AI capabilities. Supports: 证据：`projects/extension/docs/README.md`
- **install**（documentation）：Power your RAG and Agentic applications with PostgreSQL 证据：`README.md`
- **Discord Bot**（documentation）：A minimal discord bot that answers questions based on pgai's documentation via RAG. Built with python, py-cord, sqlalchemy and pgai. 证据：`examples/discord_bot/README.md`
- **Tutorial: Generating document embeddings with PGAI**（documentation）：Tutorial: Generating document embeddings with PGAI 证据：`examples/embeddings_from_documents/README.md`
- **Embedding Models Evaluation using pgai Vectorizer and LiteLLM**（documentation）：Embedding Models Evaluation using pgai Vectorizer and LiteLLM 证据：`examples/evaluations/litellm_vectorizer/README.md`
- **Readme**（documentation）：Evaluating Embedding Models: OpenAI vs. Nomic vs. BGE vs. OpenAI Large Author: Jacky Liang 证据：`examples/evaluations/ollama_vectorizer/README.md`
- **Readme**（documentation）：Domain-specific vs. General-purpose Embedding Model Evaluation Author: Jacky Liang 证据：`examples/evaluations/voyage_vectorizer/README.md`
- **Usage**（documentation）：This directory contains a simple fastAPI Application with psycopg.py that uses pgai Vectorizer to perform semantic search and RAG. The app will ingest some wikipedia articles, create vector embeddings for them, and allow you to perform semantic search and RAG. 证据：`examples/simple_fastapi_app/README.md`
- **Text-to-SQL Demo**（documentation）：The text-to-sql feature of pgai allows users to ask a natural language question and have an LLM generate a SQL statement to answer the question. 证据：`examples/text_to_sql/README.md`
- **Idempotent SQL Files**（documentation）：This directory contains SQL files which are idempotent. Any code in these scripts will be executed on EVERY install and/or upgrade. Therefore, it must be safe to re run multiple times. A good rule of thumb is that CREATE OR REPLACE statements are safe in these files. 证据：`projects/extension/sql/idempotent/README.md`
- **Incremental SQL Files**（documentation）：This directory contains SQL files which are incremental. Any code in these scripts will be executed on EXACTLY once regardless of install/upgrade path. These are typically referred to as database migrations. 证据：`projects/extension/sql/incremental/README.md`
- **notes on the changes**（documentation）：- vectorizer job - leaving ai.execute vectorizer in extension - ai. vectorizer job which calls ai.execute vectorizer is moved to dbapp 证据：`projects/pgai/db/README.md`
- **dataclasses generation for CreateVectorizerParams**（documentation）：dataclasses generation for CreateVectorizerParams This module contains a script to generate dataclasses as params for the CreateVectorizer class. If the interface for the extension is changed, running this script via uv run generate should update the dataclasses in configuration.py and vectorizer params.py without needing to manually update them. 证据：`projects/pgai/pgai/vectorizer/generate/README.md`
- **Vectorizer Load Test**（documentation）：This directory contains scripts to help with load testing the vectorizer. The scripts create a table named wiki with approximately 1.5M rows to be vectorized. 证据：`scripts/vectorizer-load-test/README.md`
- **pgai Vectorizer API reference**（documentation）：This page provides an API reference for Vectorizer functions. For an overview of Vectorizer and how it works, see the Vectorizer Guide /docs/vectorizer/overview.md . 证据：`docs/vectorizer/api-reference.md`
- **Automate AI embedding with pgai Vectorizer**（documentation）：Automate AI embedding with pgai Vectorizer 证据：`docs/vectorizer/overview.md`
- **Contributing to pgai**（documentation）：Thank you for your interest in contributing to the Timescale pgai https://github.com/timescale/pgai project! This guide outlines the process for reporting issues, proposing features, and submitting pull requests. 证据：`CONTRIBUTING.md`
- **License**（source_file）：Copyright c 2024-2025 Timescale, Inc. 证据：`LICENSE`
- **License**（source_file）：Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies. 证据：`projects/pgai/LICENSE`
- **Semantic Catalog CLI Reference**（documentation）：The pgai semantic catalog feature provides a comprehensive command-line interface for managing semantic catalogs that enable natural language to SQL functionality. This document provides detailed information about each CLI command, their usage, and their purpose in the text-to-SQL workflow. 证据：`docs/semantic_catalog/cli.md`
- **More Questions to Try**（documentation）：ID Complexity Question ---- -----------: ---------- 1 easy What is the total number of aircraft in the fleet? 2 easy How many international airports are in the database? 3 easy What is the average flight duration for all flights? 4 easy Which airports are located in Tokyo? 5 easy What is the maximum range of any aircraft in the fleet? 6 easy Which aircraft model has the highest velocity? 7 easy List all flights departing from New York's JFK airport in July 2024. 8 easy What are the names of all airports located in the United States? 9 easy How many flights were delayed in June 2024? 10 easy What are the top 10 cities with the most airports? 11 easy What is the average age of passengers who… 证据：`docs/semantic_catalog/more-questions.md`
- **Quickstart with demo data**（documentation）：We are going to use an open source postgres database named "postgres air" to demonstrate SQL generation. 证据：`docs/semantic_catalog/quickstart-demo-data.md`
- **Quickstart with your data**（documentation）：This quickstart will help you get up and running with the semantic catalog on your own database. 证据：`docs/semantic_catalog/quickstart-your-data.md`
- **Chunk text with SQL functions**（documentation）：The ai.chunk text and ai.chunk text recursively functions allow you to split text into smaller chunks. 证据：`docs/utils/chunking.md`
- **Adding a Vectorizer embedding integration**（documentation）：Adding a Vectorizer embedding integration 证据：`docs/vectorizer/adding-embedding-integration.md`
- **Alembic integration**（documentation）：Alembic is a database migration tool that allows you to manage your database schema. This document describes how to use Alembic to manage your vectorizer definitions, since those should be considered part of your database schema. 证据：`docs/vectorizer/alembic-integration.md`
- **Document embeddings in pgai**（documentation）：This is a comprehensive walkthrough of how embedding generation for documents work in pgai. If you want to get started quickly check out the runnable example /examples/embeddings from documents . 证据：`docs/vectorizer/document-embeddings.md`
- **Migrating from the extension to the python library**（documentation）：Previous versions of pgai vectorizer used an extension to provide the vectorizer functionality. We have removed the need for the extension and put the vectorizer code into the pgai python library. This change allows the vectorizer to be used on more PostgreSQL cloud providers AWS RDS, Supabase, etc. and simplifies the installation and upgrade process. 证据：`docs/vectorizer/migrating-from-extension.md`
- **Overview**（documentation）：This document describes how to create and run vectorizers from Python. 证据：`docs/vectorizer/python-integration.md`
- **Vectorizer quick start with Ollama**（documentation）：Go to our vectorizer-quickstart here /docs/vectorizer/quick-start.md to start with pgai and ollama. 证据：`docs/vectorizer/quick-start-ollama.md`
- **Pgai vectorizer S3 integration guide**（documentation）：Pgai vectorizer S3 integration guide 证据：`docs/vectorizer/s3-documents.md`
- **SQLAlchemy Integration with pgai Vectorizer**（documentation）：SQLAlchemy Integration with pgai Vectorizer 证据：`docs/vectorizer/sqlalchemy-integration.md`
- **Install pgai with Docker**（documentation）：To run pgai, you need to run two containers: 证据：`projects/extension/docs/install/docker.md`
- **Delayed embed**（documentation）：You may decide to combine pgai with Timescaledb Background Actions tsdb actions . and you can also use the pgai extension to run background actions. 证据：`projects/extension/docs/model_calling/delayed_embed.md`
- **Use pgai with Ollama**（documentation）：- Configure pgai for Ollama configure-pgai-for-ollama - Add AI functionality to your database usage 证据：`projects/extension/docs/model_calling/ollama.md`
- **Privileges**（documentation）：The ai.grant ai usage function is an important security and access control tool in the pgai extension. Its primary purpose is to grant the necessary permissions for a specified user or role to use the pgai functionality effectively and safely. This function simplifies the process of setting up appropriate access rights, ensuring that users can interact with the AI features without compromising database security. 证据：`projects/extension/docs/security/privileges.md`
- **Load dataset from Hugging Face**（documentation）：The ai.load dataset function allows you to load datasets from Hugging Face's datasets library directly into your PostgreSQL database. 证据：`projects/extension/docs/utils/load_dataset_from_huggingface.md`
- **Contributing to pgai**（documentation）：Welcome to the pgai project! This guide will help you get started with contributing to pgai, a project that brings embedding and generation AI models closer to your PostgreSQL database. 证据：`DEVELOPMENT.md`
- **Security policy**（documentation）：We aim to keep pgai safe for everyone. Publicly disclosing security bugs in a public forum can put everyone in the community at risk. Therefore, we ask that you use the following instructions to report security vulnerabilities. 证据：`SECURITY.md`
- **Working on the pgai extension**（documentation）：- pgai extension development prerequisites pgai-extension-development-prerequisites - The pgai extension development workflow the-pgai-extension-development-workflow - Controlling pgai extension tests controlling-pgai-extension-tests - The pgai extension architecture the-pgai-extension-architecture 证据：`projects/extension/DEVELOPMENT.md`
- **Pgai extension release notes**（documentation）：Use lockfile when installing prior versions when running the install-all command. 证据：`projects/extension/RELEASE_NOTES.md`
- **Changelog**（documentation）：0.12.1 https://github.com/timescale/pgai/compare/pgai-v0.12.0...pgai-v0.12.1 2025-10-13 证据：`projects/pgai/CHANGELOG.md`
- **Pgai library release notes**（documentation）：This is the first release of the Python pgai library, including the Vectorizer worker. When you have defined vectorizers /docs/vectorizer/overview.md define-a-vectorizer on a self-hosted Postgres installation, you run the Vectorizer worker /docs/vectorizer/worker.md to asynchronously processes them. 证据：`projects/pgai/RELEASE_NOTES.md`
- **.Release Please Manifest**（structured_config）：{ "projects/pgai": "0.12.1" } 证据：`.release-please-manifest.json`
- **Release Please Config**（structured_config）：{ "bootstrap-sha": "b2a936ab45c96d43dbb9e0cd81c257530a27b0d4", "packages": { "projects/pgai": { "component": "pgai", "extra-files": "pgai/data/ai.sql" } }, "separate-pull-requests": true, "include-component-in-tag": true, "release-type": "python", "bump-minor-pre-major": true, "pull-request-header": ":robot: Release ready", "changelog-sections": { "type": "feat", "section": "Features", "hidden": false }, { "type": "fix", "section": "Bug Fixes", "hidden": false }, { "type": "perf", "section": "Performance Improvements", "hidden": false }, { "type": "chore", "section": "Miscellaneous", "hidden": false } } 证据：`release-please-config.json`
- **.gitignore**（source_file）：.env .idea .venv build .egg-info pycache projects/pgai/db/sql/output/ai-- .sql projects/extension/sql/output/ai-- .sql projects/extension/tests/dump restore/describe objects.sql projects/extension/tests/dump restore/describe schemas.sql projects/extension/tests/dump restore/dump.sql projects/extension/tests/dump restore/src.snapshot projects/extension/tests/dump restore/dst.snapshot projects/pgai/db/tests/dump restore/describe objects.sql projects/pgai/db/tests/dump restore/describe schemas.sql projects/pgai/db/tests/dump restore/dump.sql projects/pgai/db/tests/dump restore/src.snapshot projects/pgai/db/tests/dump restore/dst.snapshot projects/pgai/db/tests/upgrade/ .snapshot projects/exten… 证据：`.gitignore`
- **Notice**（source_file）：Copyright c 2023-2024 Timescale, Inc. All Rights Reserved. 证据：`NOTICE`
- **Commitlint.Config**（source_file）：/ eslint-disable import/no-extraneous-dependencies / ⋮---- const validateBodyMaxLengthIgnoringDeps = parsedCommit = 证据：`commitlint.config.mjs`
- **Anonymize Entities**（source_file）：\getenv anthropic api key ANTHROPIC API KEY SELECT ai.anthropic generate 'claude-3-5-sonnet-20240620' , jsonb build array jsonb build object 'role', 'user', 'content', 'John works at Google in New York. He met with Sarah, the CEO of Acme Inc., last week in San Francisco.' , max tokens = 4096 , api key = $1 , tools = jsonb build array jsonb build object 'name', 'anonymize recognized entities', 'description', 'Anonymize recognized entities like people names, locations, companies. The output should be the original text with entities replaced by the entities recognized in the input text. Example input: John works at Google in New York. Example output: :PERSON works at :COMPANY in :CITY.', 'inpu… 证据：`examples/anonymize_entities.sql`
- **Bg Worker Moderate**（source_file）：create extension if not exists ai cascade; select set config 'ai.openai api key', :'OPENAI API KEY', false is not null as set config; DROP TABLE IF EXISTS comments CASCADE; CREATE TABLE comments id SERIAL PRIMARY KEY, body TEXT NOT NULL, created at TIMESTAMP NOT NULL DEFAULT NOW , status TEXT NOT NULL DEFAULT 'pending' ; CREATE OR REPLACE FUNCTION get moderation status body TEXT, api key TEXT RETURNS TEXT AS $$ DECLARE result JSONB; category TEXT; BEGIN select ai.openai moderate 'text-moderation-stable', body, api key - 'results'- 0 into result; IF result- 'flagged' = 'true' THEN FOR category IN SELECT jsonb object keys result- 'categories' LOOP IF result- 'categories'- category ::BOOLEAN T… 证据：`examples/bg_worker_moderate.sql`
- **Delayed Embed**（source_file）：select set config 'ai.openai api key', :'OPENAI API KEY', false is not null as set config; CREATE EXTENSION IF NOT EXISTS ai CASCADE; CREATE EXTENSION IF NOT EXISTS vectorscale CASCADE; CREATE TABLE IF NOT EXISTS document embedding id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, metadata JSONB, contents TEXT, embedding VECTOR 1536 ; CREATE INDEX document embedding idx ON document embedding USING diskann embedding ; create or replace function populate embedding job id int, config jsonb returns void as $$ declare r record; api key text; begin api key := config- 'api key'; for r in select id, contents from document embedding where embedding is null limit 1 for update skip locked loop u… 证据：`examples/delayed_embed.sql`
- **Extract Entities**（source_file）：\getenv anthropic api key ANTHROPIC API KEY CREATE OR REPLACE FUNCTION public.detect entities input text text RETURNS TABLE entity name text, entity type text, entity context text AS $$ DECLARE api response jsonb; entities json jsonb; BEGIN SELECT ai.anthropic generate 'claude-3-5-sonnet-20240620', jsonb build array jsonb build object 'role', 'user', 'content', input text , max tokens = 4096, tools = jsonb build array jsonb build object 'name', 'print entities', 'description', 'Prints extract named entities.', 'input schema', jsonb build object 'type', 'object', 'properties', jsonb build object 'entities', jsonb build object 'type', 'array', 'items', jsonb build object 'type', 'object', 'pr… 证据：`examples/extract_entities.sql`
- **Rag Report Demo Why Some Customers Donot Like Pizza**（source_file）：DROP TABLE IF EXISTS PUBLIC.pizza reviews CASCADE; DROP TABLE IF EXISTS PUBLIC.pizza reviews embeddings CASCADE; DROP TABLE IF EXISTS PUBLIC.ai report CASCADE; CREATE EXTENSION IF NOT EXISTS ai CASCADE; set ai.openai api key = 'replace you api key here or use pgai default api key environment'; select pg catalog.current setting 'ai.openai api key', true as api key; CREATE TABLE public.pizza reviews id bigserial NOT NULL, product text NOT NULL, customer message text NULL, text length INTEGER GENERATED ALWAYS AS LENGTH customer message stored, CONSTRAINT pizza reviews pkey PRIMARY KEY id ; INSERT INTO public.pizza reviews product,customer message VALUES 'pizza','The best pizza I''ve ever eaten… 证据：`examples/rag_report_demo_why_some_customers_donot_like_pizza.sql`
- **Compression**（source_file）：CREATE OR REPLACE FUNCTION public.summarize article article text text RETURNS TABLE author text, topics text , summary text, coherence integer, persuasion numeric AS $$ DECLARE api response jsonb; summary json jsonb; BEGIN SELECT ai.anthropic generate 'claude-3-5-sonnet-20240620', jsonb build array jsonb build object 'role', 'user', 'content', format 'Please summarize the following article using the print summary tool: %s', article text , max tokens = 4096, tools = jsonb build array jsonb build object 'name', 'print summary', 'description', 'Prints a summary of the article.', 'input schema', jsonb build object 'type', 'object', 'properties', jsonb build object 'author', jsonb build object '… 证据：`examples/summarize_article.sql`
- **Trigger Moderate**（source_file）：create extension if not exists ai cascade; select set config 'ai.openai api key', :'OPENAI API KEY', false is not null as set config; DROP TABLE IF EXISTS comments CASCADE; CREATE TABLE comments id SERIAL PRIMARY KEY, body TEXT NOT NULL, created at TIMESTAMP NOT NULL DEFAULT NOW , status TEXT NOT NULL DEFAULT 'pending' ; create or replace function get moderation status result jsonb returns text as $$ begin if result- 'flagged' is not null then if result- 'categories'- 'violence' then return 'violence'; end if; if result- 'categories'- 'harassment' then return 'harassment'; end if; if result- 'categories'- 'hate' then return 'hate'; end if; if result- 'categories'- 'sexual' then return 'sexu… 证据：`examples/trigger_moderate.sql`
- **pgai python library. List recipes with just -l pgai**（source_file）：export ROOT JUSTFILE := "1" Note: used in extension build.py 证据：`justfile`
- **pgai**（source_file）：Supercharge your PostgreSQL database with AI capabilities. Supports automatic creation and synchronization of vector embeddings, seamless vector and semantic search, Retrieval Augmented Generation RAG directly in SQL, and ability to call leading LLMs like OpenAI, Ollama, Cohere, and more via SQL. 证据：`llms.txt`
- **force checking absolute links within this repo overriding the exclusion below**（source_file）：verbose = "info" no progress = true exclude loopback = true accept = "403" include = force checking absolute links within this repo overriding the exclusion below we shouldn't have any absolute links like thise we should use relative links instead , so we're not too concerned about hitting rate limits. "https://github.com/timescale/pgai/blob/. ", exclude = "http://0.0.0.0:8000/ ", "https://github.com/timescale/pgai/compare/pgai-v. ", "https://github.com/timescale/pgai/commit/. ", "https://github.com/. /. /blob/. ", github has strict rate limits on these URLs exclude path = "examples/embeddings from documents/documents", contains a copy of the pgai documentation, so absolute links are all br… 证据：`lychee.toml`
- 其余 3 条证据见 `AI_CONTEXT_PACK.json` 或 `EVIDENCE_INDEX.json`。

## 宿主 AI 必须遵守的规则

- **把本资产当作开工前上下文，而不是运行环境。**：AI Context Pack 只包含证据化项目理解，不包含目标项目的可执行状态。 证据：`docs/README.md`, `docs/semantic_catalog/README.md`, `projects/extension/docs/README.md`
- **回答用户时区分可预览内容与必须安装后才能验证的内容。**：安装前体验的消费者价值来自降低误装和误判，而不是伪装成真实运行。 证据：`docs/README.md`, `docs/semantic_catalog/README.md`, `projects/extension/docs/README.md`

## 用户开工前应该回答的问题

- 你准备在哪个宿主 AI 或本地环境中使用它？
- 你只是想先体验工作流，还是准备真实安装？
- 你最在意的是安装成本、输出质量、还是和现有规则的冲突？

## 验收标准

- 所有能力声明都能回指到 evidence_refs 中的文件路径。
- AI_CONTEXT_PACK.md 没有把预览包装成真实运行。
- 用户能在 3 分钟内看懂适合谁、能做什么、如何开始和风险边界。

---

## Doramagic Context Augmentation

下面内容用于强化 Repomix/AI Context Pack 主体。Human Manual 只提供阅读骨架；踩坑日志会被转成宿主 AI 必须遵守的工作约束。

## Human Manual 骨架

使用规则：这里只是项目阅读路线和显著性信号，不是事实权威。具体事实仍必须回到 repo evidence / Claim Graph。

宿主 AI 硬性规则：
- 不得把页标题、章节顺序、摘要或 importance 当作项目事实证据。
- 解释 Human Manual 骨架时，必须明确说它只是阅读路线/显著性信号。
- 能力、安装、兼容性、运行状态和风险判断必须引用 repo evidence、source path 或 Claim Graph。

- **Overview, Architecture & Installation**：importance `high`
  - source_paths: README.md, docs/README.md, docs/vectorizer/overview.md, projects/extension/README.md, projects/pgai/README.md
- **Vectorizer & Embedding Pipeline**：importance `high`
  - source_paths: docs/vectorizer/api-reference.md, docs/vectorizer/quick-start.md, docs/vectorizer/overview.md, docs/vectorizer/document-embeddings.md, docs/vectorizer/s3-documents.md
- **Semantic Catalog & Text-to-SQL**：importance `high`
  - source_paths: docs/semantic_catalog/README.md, docs/semantic_catalog/cli.md, docs/semantic_catalog/quickstart-your-data.md, docs/semantic_catalog/quickstart-demo-data.md, docs/semantic_catalog/more-questions.md
- **Embedders, Worker & Operational Concerns**：importance `high`
  - source_paths: projects/pgai/pgai/vectorizer/embedders/openai.py, projects/pgai/pgai/vectorizer/embedders/ollama.py, projects/pgai/pgai/vectorizer/embedders/voyageai.py, projects/pgai/pgai/vectorizer/embedders/litellm.py, projects/pgai/pgai/vectorizer/embedders/__init__.py

## Repo Inspection Evidence / 源码检查证据

- repo_clone_verified: true
- repo_inspection_verified: true
- repo_commit: `47d74affd8a16d0b7f11c8f5bd6e35f7cd43abc1`
- inspected_files: `README.md`, `docs/README.md`, `docs/semantic_catalog/README.md`, `docs/semantic_catalog/cli.md`, `docs/semantic_catalog/more-questions.md`, `docs/semantic_catalog/quickstart-demo-data.md`, `docs/semantic_catalog/quickstart-your-data.md`, `docs/utils/chunking.md`, `docs/vectorizer/adding-embedding-integration.md`, `docs/vectorizer/alembic-integration.md`, `docs/vectorizer/api-reference.md`, `docs/vectorizer/document-embeddings.md`, `docs/vectorizer/migrating-from-extension.md`, `docs/vectorizer/overview.md`, `docs/vectorizer/python-integration.md`, `docs/vectorizer/quick-start-ollama.md`, `docs/vectorizer/quick-start-openai.md`, `docs/vectorizer/quick-start-voyage.md`, `docs/vectorizer/quick-start.md`, `docs/vectorizer/s3-documents.md`

宿主 AI 硬性规则：
- 没有 repo_clone_verified=true 时，不得声称已经读过源码。
- 没有 repo_inspection_verified=true 时，不得把 README/docs/package 文件判断写成事实。
- 没有 quick_start_verified=true 时，不得声称 Quick Start 已跑通。

## Doramagic Pitfall Constraints / 踩坑约束

这些规则来自 Doramagic 发现、验证或编译过程中的项目专属坑点。宿主 AI 必须把它们当作工作约束，而不是普通说明文字。

### Constraint 1: 来源证据：[Bug]: semantic catalog text to sql stuck in refinement iterations

- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：[Bug]: semantic catalog text to sql stuck in refinement iterations
- Why it matters: 可能增加新用户试用和生产接入成本。
- Evidence: community_evidence:github | https://github.com/timescale/pgai/issues/926 | 来源讨论提到 node 相关条件，需在安装/试用前复核。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 2: 来源证据：Outdated dependency versions are blocking adoption

- Trigger: GitHub 社区证据显示该项目存在一个安全/权限相关的待验证问题：Outdated dependency versions are blocking adoption
- Why it matters: 可能影响授权、密钥配置或安全边界。
- Evidence: community_evidence:github | https://github.com/timescale/pgai/issues/915 | 来源讨论提到 python 相关条件，需在安装/试用前复核。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 3: 来源证据：[Bug]: ollama_embed error on ollama higher 13.3

- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：[Bug]: ollama_embed error on ollama higher 13.3
- Why it matters: 可能增加新用户试用和生产接入成本。
- Evidence: community_evidence:github | https://github.com/timescale/pgai/issues/921 | 来源讨论提到 python 相关条件，需在安装/试用前复核。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 4: 来源证据：cannot import name 'Worker' from 'pgai'

- Trigger: GitHub 社区证据显示该项目存在一个安装相关的待验证问题：cannot import name 'Worker' from 'pgai'
- Why it matters: 可能增加新用户试用和生产接入成本。
- Evidence: community_evidence:github | https://github.com/timescale/pgai/issues/925 | 来源类型 github_issue 暴露的待验证使用条件。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 5: 来源证据：[Feature]: Use ReRank models (i.e. qwen-reranker) through Ollama

- Trigger: GitHub 社区证据显示该项目存在一个能力理解相关的待验证问题：[Feature]: Use ReRank models (i.e. qwen-reranker) through Ollama
- Host AI rule: 来源显示可能已有修复、规避或版本变化，说明书中必须标注适用版本。
- Why it matters: 可能增加新用户试用和生产接入成本。
- Evidence: community_evidence:github | https://github.com/timescale/pgai/issues/866 | 来源类型 github_issue 暴露的待验证使用条件。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 6: 能力判断依赖假设

- Trigger: README/documentation is current enough for a first validation pass.
- Host AI rule: 将假设转成下游验证清单。
- Why it matters: 假设不成立时，用户拿不到承诺的能力。
- Evidence: capability.assumptions | https://github.com/timescale/pgai | README/documentation is current enough for a first validation pass.
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 7: 来源证据：HTTP client connection leak in embedders causes file descriptor exhaustion

- Trigger: GitHub 社区证据显示该项目存在一个运行相关的待验证问题：HTTP client connection leak in embedders causes file descriptor exhaustion
- Why it matters: 可能增加新用户试用和生产接入成本。
- Evidence: community_evidence:github | https://github.com/timescale/pgai/issues/919 | 来源类型 github_issue 暴露的待验证使用条件。
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 8: 维护活跃度未知

- Trigger: 未记录 last_activity_observed。
- Host AI rule: 补 GitHub 最近 commit、release、issue/PR 响应信号。
- Why it matters: 新项目、停更项目和活跃项目会被混在一起，推荐信任度下降。
- Evidence: evidence.maintainer_signals | https://github.com/timescale/pgai | last_activity_observed missing
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

- Trigger: no_demo
- Evidence: downstream_validation.risk_items | https://github.com/timescale/pgai | no_demo; severity=medium
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。

### Constraint 10: 存在评分风险

- Trigger: no_demo
- Why it matters: 风险会影响是否适合普通用户安装。
- Evidence: risks.scoring_risks | https://github.com/timescale/pgai | no_demo; severity=medium
- Hard boundary: 不要把这个坑点包装成已解决、已验证或可忽略，除非后续验证证据明确证明它已经关闭。
