-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy path.coderabbit.yaml
More file actions
278 lines (249 loc) · 13.5 KB
/
Copy path.coderabbit.yaml
File metadata and controls
278 lines (249 loc) · 13.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# CodeRabbit Configuration for qdrant-loader monorepo
# Schema: https://coderabbit.ai/integrations/schema.v2.json
language: "en-US"
tone_instructions: "Be direct and precise. Focus on correctness, resource safety, and security. Flag real bugs and risks, not style nits already handled by Ruff and Black. For every issue flagged, provide a corrected code snippet and a one-sentence rationale."
reviews:
profile: assertive
auto_review:
enabled: true
drafts: false
base_branches:
- main
- develop
path_filters:
- "**/*"
- "!**/*.md"
- "!**/docs/**"
- "!**/website/**"
- "!**/.egg-info/**"
- "!**/__pycache__/**"
- "!**/dist/**"
- "!**/*.lock"
high_level_summary_instructions: >
Summarise: (1) which connectors or pipeline stages are affected,
(2) any config schema changes that are breaking or additive,
(3) whether tests cover the changed code paths,
(4) any security or resource-safety concerns.
Keep it under 150 words.
auto_title_instructions: >
Follow Conventional Commits: type(scope): description.
Valid types: feat, fix, refactor, perf, test, docs, ci, chore.
Scope should be the package or connector name (e.g. confluence, git, state, mcp-server).
path_instructions:
- path: "packages/qdrant-loader/src/qdrant_loader/connectors/**"
instructions: >
This is the connector layer — the highest-risk area of the codebase.
Check for:
- Every connector must use `async with` or implement `__aenter__`/`__aexit__`
to guarantee session cleanup. Flag any code path where a `requests.Session`
or aiohttp session could leak if an exception is raised.
- Rate limiting: verify that any new HTTP calls go through the shared
RateLimiter in `connectors/shared/http.py`, not raw `requests.get()`.
- Pagination: ensure all paginated API calls handle empty pages and
off-by-one termination conditions correctly.
- Authentication headers must never appear in log output. All exception
messages must pass through `sanitize_exception_message()` before logging.
- Bare `except Exception:` blocks are not acceptable — catch specific
exceptions (HTTPError, ConnectionError, TimeoutError) and re-raise or
handle deliberately.
- Connector registry: if a new connector is added, verify it is registered
in `connectors/registry.py` and has a corresponding factory entry.
- `get_documents()` must be `async def` and must yield or return a list of
`Document` objects — no silent empty returns on error.
- path: "packages/qdrant-loader/src/qdrant_loader/connectors/confluence/**"
instructions: >
Confluence connector supports Cloud (BasicAuth) and Data Center (Bearer).
Check for:
- Any new auth logic must handle both deployment types; look for missing
`if self.deployment_type == DeploymentType.CLOUD` branches.
- Attachment downloads are a resource-leak hotspot — verify temp files and
file handles are always closed in `finally` blocks or context managers.
- Rate limiting must apply to attachment downloads as well as page fetches.
- Pagination cursors (`_links.next`) must be followed until absent;
flag any loop that terminates on a fixed page count.
- path: "packages/qdrant-loader/src/qdrant_loader/connectors/git/**"
instructions: >
Git connector clones repos and traverses files using GitPython.
Check for:
- Command injection risk: branch names, repo URLs, and file paths from
config must never be interpolated into shell commands. Verify all
GitPython calls use object APIs, not `repo.git.execute()` with
user-supplied strings.
- Large repo handling: ensure timeouts and size limits are enforced before
clone completes to avoid filling disk.
- Credential leakage: SSH key paths and HTTPS tokens must not appear in
exception messages or debug logs.
- Temp directories created for cloning must be cleaned up on exception paths.
- path: "packages/qdrant-loader/src/qdrant_loader/connectors/jira/**"
instructions: >
Jira connector has separate Cloud and Data Center implementations.
Check for:
- Auth handling must cover both Cloud (Basic Auth with API token) and
Data Center (Bearer token); flag any new auth code missing one branch.
- Issue traversal must handle pagination via `startAt`/`maxResults` correctly;
flag any loop that stops before `total` is reached.
- Changelog fetching is optional — verify it is gated on config and does not
silently fail if the field is absent from the API response.
- Exception messages must pass through `sanitize_exception_message()` to
prevent token or email leakage in logs.
- path: "packages/qdrant-loader/src/qdrant_loader/connectors/localfile/**"
instructions: >
Local file connector scans directories and converts via MarkItDown.
Check for:
- Path traversal: user-supplied directory paths must be resolved and
validated to stay within the configured root; flag any `open()` call
without a bounds check.
- File size limits must be enforced before reading into memory; flag any
file read without a size guard.
- All file handles must be closed in `finally` blocks or context managers —
no bare `open()` without `with`.
- Unsupported file types must be skipped gracefully, not raise unhandled
exceptions that abort the entire ingestion run.
- path: "packages/qdrant-loader/src/qdrant_loader/connectors/publicdocs/**"
instructions: >
Public docs connector crawls URLs and parses HTML with BeautifulSoup.
Check for:
- URL validation: crawl targets must be validated as `http`/`https` before
requests are made; flag any URL constructed from config without scheme check.
- Crawl scope must be bounded — verify the connector does not follow
off-domain links or exceed a configured depth/page limit.
- Rate limiting must apply to all outbound HTTP requests; flag any `requests`
call that bypasses the shared RateLimiter.
- BeautifulSoup parsing must use `html.parser` or `lxml`, never `html5lib`
with untrusted content unless explicitly reviewed for safety.
- path: "packages/qdrant-loader/src/qdrant_loader/core/state/**"
instructions: >
State management uses SQLAlchemy with connection pooling.
Check for:
- Every DB operation must be inside a transaction that is explicitly
committed or rolled back. Flag missing `session.rollback()` on exception
paths.
- Connection pool exhaustion: verify that all sessions are returned to the
pool (use context managers, not manual `session.close()`).
- Schema migrations: if a model field is added/removed, flag the missing
Alembic migration.
- No raw string SQL — all queries must use SQLAlchemy ORM or parameterised
text clauses. Flag any `text(f"... {variable}")` patterns.
- path: "packages/qdrant-loader/src/qdrant_loader/core/pipeline/**"
instructions: >
Pipeline orchestrator and workers handle concurrent async processing.
Check for:
- Exception handling in workers must not silently swallow errors that
should fail the pipeline. Verify that worker exceptions propagate or
are surfaced in the run summary.
- Force flag (`--force`) bypasses change detection — flag any expansion
of its scope or new code that ignores the force flag unintentionally.
- Concurrency controls: verify that new workers respect the configured
concurrency limits and do not spawn unbounded tasks.
- Project context: verify null checks for `project_id` and `project_config`
before use in all pipeline stages.
- path: "packages/qdrant-loader/src/qdrant_loader/core/file_conversion/**"
instructions: >
File conversion uses MarkItDown with ffmpeg for audio, PDF parsing, Office docs.
Check for:
- All file handles and temp files must be closed/deleted in `finally` blocks
or via context managers — no path should leave orphaned temp files.
- Timeouts must be enforced for ffmpeg and external process calls.
- Large file guards: flag any conversion that reads the entire file into
memory without a size check.
- Malicious file content: MarkItDown processes arbitrary user files —
verify no shell expansion or eval of file content occurs.
- LLM API key in `to_dict()` / config dumps: the `llm_api_key` field must
be masked (e.g. `***`) in any serialisation used for logging or display.
- path: "packages/qdrant-loader/src/qdrant_loader/config/**"
instructions: >
Pydantic V2 config models are the trust boundary for user input.
Check for:
- New fields must have explicit validators or constrained types (e.g.
`AnyHttpUrl`, `PositiveInt`, `constr(min_length=1)`).
- Any field that holds a secret (api_key, token, password) must use
`SecretStr` or be excluded from `model_dump()` / `__repr__`.
- YAML loading must use `yaml.safe_load()`, never `yaml.load()`.
- Environment variable expansion must not allow interpolation of one secret
into an unrelated field.
- Breaking config schema changes (renamed/removed fields) must include a
migration note or deprecation warning.
- path: "packages/qdrant-loader-mcp-server/**"
instructions: >
MCP server exposes semantic search via stdio and HTTP (FastAPI).
Check for:
- All FastAPI route handlers must validate input with Pydantic models —
no raw `request.body()` parsing.
- Errors returned to MCP clients must not include internal stack traces
or credential values.
- Async route handlers must not block the event loop with synchronous I/O.
- Any new MCP tool must be registered in the tool registry and have a
corresponding integration test.
- HTTP transport: verify CORS settings are not overly permissive for
production deployments.
- path: "packages/qdrant-loader-core/**"
instructions: >
Core LLM abstraction used by both qdrant-loader and mcp-server.
Check for:
- New LLM providers must implement the full `LLMProvider` interface —
flag missing method implementations.
- Rate limiting and retry logic must be consistent across providers.
- Token counting must account for the correct model's context window;
flag hardcoded token limits.
- Dependencies added here affect all downstream packages — flag any
new dependency that is not strictly necessary.
- path: ".github/workflows/**"
instructions: >
Check for:
- Secrets must only be injected into jobs that require them; flag any
`${{ secrets.* }}` exposure in steps that run on fork PRs.
- `pull_request_target` triggers must be audited carefully for injection
risk — prefer `pull_request` for untrusted code.
- Pinned action versions (`uses: actions/checkout@v4`) are good; flag
any unpinned `@main` or `@master` references.
- New jobs should use concurrency groups to cancel stale runs.
- path: "pyproject.toml"
instructions: >
Check for:
- New dependencies should have a minimum version pin.
- Dev-only dependencies must not appear in the main `[project.dependencies]`.
- Version bumps in `[project]` must be consistent across all three packages
if it is a coordinated release.
pre_merge_checks:
custom_checks:
- name: "No hardcoded secrets or tokens"
instructions: >
Fail if any hardcoded API key, token, password, or secret appears in
non-test source code. Look for patterns like `api_key = "sk-..."`,
`token = "ghp_..."`, `password = "..."`, or any string resembling a
credential assigned to a variable.
- name: "Async context managers on all connectors"
instructions: >
Fail if a connector class that inherits from BaseConnector does not
implement `__aenter__` and `__aexit__`, or if connector instances are
used without `async with` in the calling code.
- name: "No bare except in connector or pipeline code"
instructions: >
Fail if `except:` or `except Exception:` appears in any file under
`connectors/` or `core/pipeline/` without a specific comment explaining
why a broad catch is intentional.
- name: "SecretStr for credential fields"
instructions: >
Fail if a new Pydantic model field whose name contains 'key', 'token',
'password', 'secret', or 'credential' uses a plain `str` type instead
of `pydantic.SecretStr`.
- name: "Tests exist for new connectors"
instructions: >
Fail if a new connector module is added under `connectors/` but no
corresponding test file exists under `tests/unit/connectors/` or
`tests/integration/connectors/`.
tools:
ruff:
enabled: true
semgrep:
enabled: true
trufflehog:
enabled: true
yamllint:
enabled: true
actionlint:
enabled: true
hadolint:
enabled: true
chat:
auto_reply: true