Skip to content

feat: add MongoDB driver support - #482

Merged
anandgupta42 merged 5 commits into
mainfrom
feat/mongodb-driver
Mar 26, 2026
Merged

feat: add MongoDB driver support#482
anandgupta42 merged 5 commits into
mainfrom
feat/mongodb-driver

Conversation

@anandgupta42

@anandgupta42anandgupta42 commented Mar 26, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds MongoDB as the 11th supported database driver, enabling document database operations via the existing Connector interface. This is needed for the DataAgentBench (DAB) benchmark where 2 of 12 datasets require MongoDB.

Changes:

  • New driver at packages/drivers/src/mongodb.ts with full MQL command set (find, aggregate, CRUD, indexes, collection management)
  • Cross-database queries via per-query database field override
  • BSON type serialization (ObjectId, Decimal128, Long, UUID, Binary, Date)
  • Schema introspection via document sampling with accurate nullable detection
  • Connection string URI and host/port auth support
  • authorizedDatabases fallback for restricted-privilege users
  • Registration in driver index, config normalizer (mongo/mongodb aliases), and connection registry
  • CI: MongoDB 7.0 service in driver-e2e workflow with health checks
  • 90 E2E tests: CRUD, aggregation, schema introspection, cross-DB ops, indexes, adversarial edge cases

Type of change

  • New feature (non-breaking change which adds functionality)

Issue for this PR

Closes#480
Closes#481

How did you verify your code works?

  • All 90 MongoDB E2E tests pass against Dockerized MongoDB 7.0
  • Existing driver tests (DuckDB, SQLite, PostgreSQL, normalize, connections) all pass — zero regressions
  • TypeScript typecheck passes
  • Marker check passes (no upstream files modified)
  • Multi-model code review (Claude + GPT 5.2 Codex + 4 others): review findings addressed before commit

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • New and existing unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a MongoDB database driver with host/port or connection-string connection, schema discovery, and broad operation support (CRUD, aggregation, indexes).
  • Tests

    • Added comprehensive end-to-end tests covering connection, CRUD, aggregation, schema introspection, indexes, and error cases.
  • CI

    • Integrated MongoDB service into CI and added an E2E test step to run the MongoDB test suite.

Add MongoDB as the 11th supported database driver, enabling document
database operations via the existing `Connector` interface.
- New driver at `packages/drivers/src/mongodb.ts` supporting:
- Full MQL command set: find, aggregate, CRUD, indexes, collection mgmt
- Cross-database queries via per-query `database` field
- BSON type serialization (ObjectId, Decimal128, Long, UUID, Binary, Date)
- Schema introspection via document sampling with field type inference
- Connection string URI and host/port/user/password auth
- `authorizedDatabases` fallback for restricted-privilege users
- Registration in driver index, config normalizer (with `mongo`/`mongodb` aliases), and connection registry
- CI: MongoDB 7.0 service in driver-e2e workflow with health checks
- 90 E2E tests including:
- CRUD operations, aggregation pipelines, schema introspection
- Cross-database operations, index management, collection lifecycle
- Adversarial tests: deeply nested docs, special characters, heterogeneous
collections, concurrent operations, large documents, numeric edge cases
Closes#480
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@claudeclaudeBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitaiBot commented Mar 26, 2026

Copy link
Copy Markdown

Caution

Review failed

An error occurred during the review process. Please try again later.

📝 Walkthrough

Walkthrough

Adds a MongoDB driver and CI/test integration: new driver implementation (connect, schema introspection, JSON MQL execution), registry and normalization updates, optional dependency entry, and a comprehensive Docker-capable end-to-end test plus CI changes to run it.

Changes

Cohort / File(s)Summary
CI Workflow
.github/workflows/ci.yml
Expanded change-detection to include the new MongoDB E2E test; added a mongodb service (mongo:7.0) with a mongosh health check; added a CI step to run the MongoDB E2E test with TEST_MONGODB_HOST/PORT.
Package manifest
packages/drivers/package.json
Added mongodb: ^6.0.0 to optionalDependencies.
Driver implementation
packages/drivers/src/mongodb.ts, packages/drivers/src/index.ts
New MongoDB connector exporting connect(config), managing MongoClient lifecycle, schema introspection (listSchemas, listTables, describeTable via sampling), BSON-aware serialization, and execute(query) supporting MQL commands (find, aggregate, CRUD, index ops); re-exported as connectMongodb.
Normalization & aliases
packages/drivers/src/normalize.ts
Added MONGODB_ALIASES and registered aliases for mongodb/mongo (e.g., usernameuser, uri/urlconnection_string, dbnamedatabase, connection-timeout keys).
Connector registry & runtime
packages/opencode/src/altimate/native/connections/registry.ts
Registered mongodb/mongo in DRIVER_MAP; added static import/case for the mongodb driver; detectAuthMethod returns password if config.password else connection_string for MongoDB; test runner uses a MongoDB ping JSON command for health checks when driver is MongoDB.
End-to-end tests
packages/opencode/test/altimate/drivers-mongodb-e2e.test.ts
Added comprehensive E2E test file with Docker auto-detection and optional container startup; covers connection variants, lifecycle/close behavior, broad CRUD and aggregation scenarios, schema introspection, collection/index management, adversarial/error-case tests, BSON serialization checks, and cleanup logic.

Sequence Diagram(s)

sequenceDiagram
participant App as Application
participant Driver as MongoDB Driver
participant MClient as MongoClient
participant Server as MongoDB Server
App->>Driver: connect(config)
activate Driver
Driver->>MClient: new MongoClient(uri, options)
activate MClient
MClient->>Server: TCP connect & auth
Server-->>MClient: Connected
MClient-->>Driver: client instance
Driver-->>App: Connector
deactivate Driver
rect rgba(200, 150, 255, 0.5)
Note over App,Driver: Execute JSON MQL
App->>Driver: execute(JSON query)
activate Driver
Driver->>Driver: parse & validate
Driver->>MClient: call op (find/aggregate/insert/...)
activate MClient
MClient->>Server: run operation
Server-->>MClient: cursor/data
MClient-->>Driver: result
Driver->>Driver: serialize BSON -> rows
Driver-->>App: ConnectorResult
deactivate Driver
end
rect rgba(150, 200, 255, 0.5)
Note over App,Driver: Introspection flow
App->>Driver: listSchemas() / listTables() / describeTable()
Driver->>MClient: admin/listDatabases / listCollections / find(limit=100)
MClient->>Server: fetch metadata / sample docs
Server-->>MClient: metadata / documents
MClient-->>Driver: data
Driver-->>App: schemas/tables/columns
end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 In a burrow of BSON and curious code,
I sniffed out collections down a new road.
Find, aggregate, index—the carrots all gleam,
Altimate hops forward, a developer's dream! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check nameStatusExplanationResolution
Docstring Coverage⚠️ WarningDocstring coverage is 46.67% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check nameStatusExplanation
Title check✅ PassedThe title 'feat: add MongoDB driver support' is clear, concise, and accurately reflects the main change—adding MongoDB as a new database driver to the system.
Description check✅ PassedThe PR description includes a clear summary of changes, verification of testing including the 90 E2E tests, and a checklist. However, it does not follow the provided template structure with 'Summary', 'Test Plan', and 'Checklist' sections.
Linked Issues check✅ PassedThe PR comprehensively implements all coding objectives from #480: MongoDB driver with full MQL support, schema introspection, BSON serialization, connection options, registration, CI integration, and 90 E2E tests. Issue #481 is coordination-only.
Out of Scope Changes check✅ PassedAll changes are directly in scope: MongoDB driver implementation, supporting infrastructure (normalization, registry, CI), and comprehensive E2E tests. No modifications to unrelated systems or files detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/mongodb-driver

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Fixes from 6-model consensus review (Claude, GPT 5.2 Codex, Gemini 3.1
Pro, Kimi K2.5, MiniMax M2.5, GLM-5):
- Cap user-specified `limit` against `effectiveLimit` to prevent OOM
from unbounded queries (flagged by Gemini)
- Add `ping` command for connection testing instead of querying
`system.version` which may not be accessible (flagged by Gemini, GLM-5)
- Add `e.code === 26` fallback for `dropCollection` error handling
across MongoDB versions (flagged by GLM-5)
- Fix misleading docstring on `extractFields` that claimed dot-notation
expansion (flagged by Gemini)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
packages/drivers/src/normalize.ts (1)

76-85: Consider using COMMON_ALIASES spread for consistency.

Other drivers (Postgres, Redshift, MySQL, SQL Server, Oracle) spread COMMON_ALIASES to inherit the common user and database mappings. The MongoDB aliases define these inline, which duplicates the same mappings. This works correctly but is inconsistent with the established pattern.

♻️ Suggested refactor for consistency
 const MONGODB_ALIASES: AliasMap = {
- user: ["username"],- database: ["dbname", "db"],+ ...COMMON_ALIASES,
connection_string: ["connectionString", "uri", "url"],
auth_source: ["authSource"],
replica_set: ["replicaSet"],
direct_connection: ["directConnection"],
connect_timeout: ["connectTimeoutMS"],
server_selection_timeout: ["serverSelectionTimeoutMS"],
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/drivers/src/normalize.ts` around lines 76 - 85, MONGODB_ALIASES
currently redeclares the common mappings for user and database; update it to
spread COMMON_ALIASES into MONGODB_ALIASES (e.g., const MONGODB_ALIASES:
AliasMap = { ...COMMON_ALIASES, /* mongo-specific keys */ }) and then include
only MongoDB-specific aliases (connection_string, auth_source, replica_set,
direct_connection, connect_timeout, server_selection_timeout), removing the
duplicate user and database entries to match the other drivers' pattern.
packages/drivers/src/mongodb.ts (1)

328-362: Aggregate $limit detection could miss nested stages.

The check lastStage && "$limit" in lastStage only examines the last pipeline stage. If users have a $limit buried in the middle of the pipeline (intentionally wanting full results), the auto-appended $limit will still truncate. This is documented behavior (you append if "pipeline doesn't already end with one"), so it's acceptable, but consider documenting that users should place their own $limit last if they want to control truncation precisely.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/drivers/src/mongodb.ts` around lines 328 - 362, The current
aggregate branch only checks the last pipeline stage (`lastStage` / `hasLimit`)
for a $limit and can wrongly append a new $limit when one exists earlier; update
the detection to scan the entire parsed.pipeline (e.g., replace the `hasLimit`
logic with a check like `pipeline.some(stage => "$limit" in stage)`) so you only
push `{ $limit: effectiveLimit + 1 }` when no stage in `parsed.pipeline`
contains `$limit`; ensure you still preserve existing behavior of cloning
`parsed.pipeline` into `pipeline` and use `coll.aggregate(pipeline).toArray()`
and keep the rest of the logic unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/drivers/package.json`:
- Around line 19-20: Update the mongodb dependency version in
packages/drivers/package.json from "mongodb": "^6.0.0" to "mongodb": "^7.0.0" so
the project can pull the latest stable 7.x releases; after changing the
dependency string, run your package manager to update the lockfile
(npm/yarn/pnpm install) and run the test suite/build to ensure no breaking API
changes affect code using the MongoClient or other mongodb-related symbols.
---
Nitpick comments:
In `@packages/drivers/src/mongodb.ts`:
- Around line 328-362: The current aggregate branch only checks the last
pipeline stage (`lastStage` / `hasLimit`) for a $limit and can wrongly append a
new $limit when one exists earlier; update the detection to scan the entire
parsed.pipeline (e.g., replace the `hasLimit` logic with a check like
`pipeline.some(stage => "$limit" in stage)`) so you only push `{ $limit:
effectiveLimit + 1 }` when no stage in `parsed.pipeline` contains `$limit`;
ensure you still preserve existing behavior of cloning `parsed.pipeline` into
`pipeline` and use `coll.aggregate(pipeline).toArray()` and keep the rest of the
logic unchanged.
In `@packages/drivers/src/normalize.ts`:
- Around line 76-85: MONGODB_ALIASES currently redeclares the common mappings
for user and database; update it to spread COMMON_ALIASES into MONGODB_ALIASES
(e.g., const MONGODB_ALIASES: AliasMap = { ...COMMON_ALIASES, /* mongo-specific
keys */ }) and then include only MongoDB-specific aliases (connection_string,
auth_source, replica_set, direct_connection, connect_timeout,
server_selection_timeout), removing the duplicate user and database entries to
match the other drivers' pattern.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e11fc510-0761-4a43-919e-0c5ae0a1c567

📥 Commits

Reviewing files that changed from the base of the PR and between 91fe351 and e431850.

⛔ Files ignored due to path filters (1)
  • bun.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • .github/workflows/ci.yml
  • packages/drivers/package.json
  • packages/drivers/src/index.ts
  • packages/drivers/src/mongodb.ts
  • packages/drivers/src/normalize.ts
  • packages/opencode/src/altimate/native/connections/registry.ts
  • packages/opencode/test/altimate/drivers-mongodb-e2e.test.ts

Comment on lines +19 to +20
"duckdb": "^1.0.0",
"mongodb": "^6.0.0"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

What is the latest stable version of the mongodb npm package?

💡 Result:

The latest stable version of the mongodb npm package is 7.1.1.

Citations:


Update mongodb package to latest stable version.

The mongodb ^6.0.0 constraint excludes the latest stable release (7.1.1). Update to ^7.0.0 to include security patches and bug fixes from the latest major version.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/drivers/package.json` around lines 19 - 20, Update the mongodb
dependency version in packages/drivers/package.json from "mongodb": "^6.0.0" to
"mongodb": "^7.0.0" so the project can pull the latest stable 7.x releases;
after changing the dependency string, run your package manager to update the
lockfile (npm/yarn/pnpm install) and run the test suite/build to ensure no
breaking API changes affect code using the MongoClient or other mongodb-related
symbols.

@coderabbitaicoderabbitaiBot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/drivers/src/mongodb.ts (1)

191-194: Redundant logic in serializeValue — both branches produce identical output.

Lines 191-194 always call JSON.stringify(val) regardless of which branch is taken. The conditional serves no purpose.

♻️ Simplify to a single JSON.stringify call
 // Arrays and plain objects — JSON-serialize for tabular display
- if (Array.isArray(val) || typeof (val as any).toJSON !== "function") {- return JSON.stringify(val)- }
return JSON.stringify(val)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/drivers/src/mongodb.ts` around lines 191 - 194, The conditional in
serializeValue is redundant because both branches call JSON.stringify(val);
simplify by removing the if/else and returning JSON.stringify(val) directly from
the serializeValue function (locate the serializeValue function and replace the
conditional block starting with "if (Array.isArray(val) || typeof (val as
any).toJSON !== \"function\")" with a single return JSON.stringify(val)).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/drivers/src/mongodb.ts`:
- Around line 382-395: The distinct branch returns raw BSON values from
coll.distinct without serialization; update the code in the "distinct" case to
pass each value through the existing serializeValue function before constructing
rows (e.g., when building limited.map((v) => [serializeValue(v)]) ), keeping the
truncated/limited logic and columns: [parsed.field] and row_count based on
limited.length unchanged so the response matches how find/aggregate return
serialized tabular values.
- Around line 336-370: The aggregate branch doesn't cap a user-specified $limit,
so a pipeline ending in { $limit: N } can return more than effectiveLimit and
risk OOM; update the pipeline before calling coll.aggregate by inspecting
parsed.pipeline's lastStage: if lastStage has "$limit", replace its value with
Math.min(userLimit, effectiveLimit + 1) (so truncated detection remains
correct), otherwise append { $limit: effectiveLimit + 1 } as currently done;
operate on the local pipeline array (the one created from parsed.pipeline) so
coll.aggregate(pipeline).toArray() uses the capped limit.
---
Nitpick comments:
In `@packages/drivers/src/mongodb.ts`:
- Around line 191-194: The conditional in serializeValue is redundant because
both branches call JSON.stringify(val); simplify by removing the if/else and
returning JSON.stringify(val) directly from the serializeValue function (locate
the serializeValue function and replace the conditional block starting with "if
(Array.isArray(val) || typeof (val as any).toJSON !== \"function\")" with a
single return JSON.stringify(val)).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b676f8db-554c-452d-935d-599b0d84a98e

📥 Commits

Reviewing files that changed from the base of the PR and between e431850 and b5e060c.

📒 Files selected for processing (2)
  • packages/drivers/src/mongodb.ts
  • packages/opencode/src/altimate/native/connections/registry.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/opencode/src/altimate/native/connections/registry.ts

Comment threadpackages/drivers/src/mongodb.ts
Comment on lines +382 to +395
case "distinct": {
if (!parsed.field) {
throw new Error("distinct requires a 'field' string")
}
const values = await coll.distinct(parsed.field, parsed.filter ?? {})
const truncated = values.length > effectiveLimit
const limited = truncated ? values.slice(0, effectiveLimit) : values
return {
columns: [parsed.field],
rows: limited.map((v: unknown) => [v]),
row_count: limited.length,
truncated,
}
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Distinct values are not serialized, unlike find and aggregate results.

Values returned by distinct may include BSON types (ObjectId, Decimal128, etc.), but they are returned as-is without passing through serializeValue. This is inconsistent with find and aggregate which serialize all values for tabular display.

🔧 Proposed fix to serialize distinct values
 const values = await coll.distinct(parsed.field, parsed.filter ?? {})
const truncated = values.length > effectiveLimit
const limited = truncated ? values.slice(0, effectiveLimit) : values
return {
columns: [parsed.field],
- rows: limited.map((v: unknown) => [v]),+ rows: limited.map((v: unknown) => [serializeValue(v)]),
row_count: limited.length,
truncated,
}
📝 Committable suggestion

‼️IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
case"distinct": {
if(!parsed.field){
thrownewError("distinct requires a 'field' string")
}
constvalues=awaitcoll.distinct(parsed.field,parsed.filter??{})
consttruncated=values.length>effectiveLimit
constlimited=truncated ? values.slice(0,effectiveLimit) : values
return{
columns: [parsed.field],
rows: limited.map((v: unknown)=>[v]),
row_count: limited.length,
truncated,
}
}
case"distinct": {
if(!parsed.field){
thrownewError("distinct requires a 'field' string")
}
constvalues=awaitcoll.distinct(parsed.field,parsed.filter??{})
consttruncated=values.length>effectiveLimit
constlimited=truncated ? values.slice(0,effectiveLimit) : values
return{
columns: [parsed.field],
rows: limited.map((v: unknown)=>[serializeValue(v)]),
row_count: limited.length,
truncated,
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@packages/drivers/src/mongodb.ts` around lines 382 - 395, The distinct branch
returns raw BSON values from coll.distinct without serialization; update the
code in the "distinct" case to pass each value through the existing
serializeValue function before constructing rows (e.g., when building
limited.map((v) => [serializeValue(v)]) ), keeping the truncated/limited logic
and columns: [parsed.field] and row_count based on limited.length unchanged so
the response matches how find/aggregate return serialized tabular values.

CodeRabbit review fixes:
- Use `...COMMON_ALIASES` spread in `MONGODB_ALIASES` for consistency
with other drivers (normalize.ts)
- Scan entire aggregate pipeline for `$limit` instead of only last
stage; also skip auto-limit for `$out`/`$merge` write pipelines
- Keep `mongodb` at `^6.0.0` (NOT upgrading to v7): v7 drops Node 16/18
support and has many breaking changes; v6.21.0 is actively maintained
and supports MongoDB server 3.6-8.0
Additional review fixes:
- Include database name in URI when building from individual config
fields for correct auth-source resolution (GLM-5)
- Add security comment about credential exposure in URI (Kimi K2.5)
Documentation updates:
- `docs/docs/drivers.md`: add MongoDB to support matrix (11 databases),
install section, auth methods, auto-discovery
- `docs/docs/configure/warehouses.md`: add MongoDB configuration section
with connection string and field-based examples, server compatibility
- `docs/docs/data-engineering/tools/warehouse-tools.md`: add MongoDB to
Docker discovery and env var detection
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@anandgupta42

Copy link
Copy Markdown
ContributorAuthor

Addressed all CodeRabbit findings in 56acab4:

Version upgrade (^6.0.0^7.0.0) — intentionally NOT upgrading: mongodb v7 drops Node 16/18 support and has many breaking changes. v6.21.0 (latest v6) is actively maintained and supports MongoDB server 3.6 through 8.0, covering all releases from the last 3+ years.

Nitpicks addressed:

  • COMMON_ALIASES spread in MONGODB_ALIASES for consistency
  • ✅ Aggregate $limit detection now scans entire pipeline (not just last stage), and skips $out/$merge write pipelines

Additional fixes in this commit:

  • Include database in URI for correct auth-source resolution
  • Security comment about credential exposure
  • Full documentation updates (drivers.md, warehouses.md, warehouse-tools.md)

anandgupta42and others added 2 commits March 26, 2026 12:06
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Cap user-specified `$limit` in aggregate pipelines against
`effectiveLimit` to prevent OOM, matching the `find` command behavior
- Serialize `distinct` return values through `serializeValue()` for
consistent BSON type handling across find/aggregate/distinct
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@anandgupta42
anandgupta42 merged commit abcaa1d into mainMar 26, 2026
10 checks passed
@anandgupta42
anandgupta42 deleted the feat/mongodb-driver branch March 26, 2026 19:38
anandgupta42 pushed a commit that referenced this pull request Mar 26, 2026
MongoDB driver was added in PR #482 but its config alias normalization
had zero unit test coverage. These tests ensure camelCase config keys
(connectionString, uri, authSource, replicaSet, etc.) resolve correctly,
preventing silent connection failures for users providing non-canonical
config field names.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
https://claude.ai/code/session_019D8HyMGHH3Pf43PddTqUw5
anandgupta42 pushed a commit that referenced this pull request Mar 26, 2026
Cover two untested code paths in the connection registry:
1. ALTIMATE_CODE_CONN_* env var parsing (CI/Docker users)
2. MongoDB-specific detectAuthMethod branches added in #482
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
https://claude.ai/code/session_015egWH6W5HdaVuMysv9tFHq
anandgupta42 pushed a commit that referenced this pull request Mar 26, 2026
MongoDB driver (PR #482) had zero unit tests for config alias normalization
(uri, url, authSource, etc.) and auth method detection in telemetry. These
tests prevent silent config failures for MongoDB users using common alias
field names and ensure telemetry correctly categorizes auth methods for all
driver types including the new MongoDB and file-based drivers.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kulvirgit added a commit that referenced this pull request Mar 27, 2026
- Add 9 driver import checks to verify-install.sh: pg, snowflake-sdk,
mysql2, mssql, duckdb, mongodb, bigquery, databricks, oracledb (#295)
- Install all driver packages in Dockerfile so tests don't skip
- Add MongoDB service to docker-compose.yml (PR #482 added the driver)
- Add mongodb smoke test alongside existing postgres/snowflake tests
- Add mongodb E2E step to ci-local.sh full mode
- Bump Docker healthy count from 4 to 5 (includes mongodb)
- Add driver-change PR trigger to generate.sh
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
anandgupta42 pushed a commit that referenced this pull request Mar 27, 2026
MongoDB was added in #482 but normalizeConfig() lacked any MongoDB-specific
tests. These 11 tests verify that common field name aliases (uri, url,
connectionString, authSource, replicaSet, directConnection, username, dbname,
timeout fields) are correctly resolved to their canonical snake_case names,
preventing silent connection failures when users provide MongoDB config from
dbt profiles, MongoDB docs, or LLM-generated output.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
https://claude.ai/code/session_01UtQ9rqYTKybuvdu6bM4cTj
anandgupta42 pushed a commit that referenced this pull request Mar 27, 2026
Cover the MongoDB aliases added in #482 and the MongoDB-specific branch
in detectAuthMethod. Without these tests, camelCase config field names
from LLMs or dbt profiles (connectionString, authSource, replicaSet)
could silently fail to normalize, preventing MongoDB connections.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
anandgupta42 pushed a commit that referenced this pull request Mar 27, 2026
The MongoDB driver was added in #482 but driver-normalize.test.ts had zero
tests for the MONGODB_ALIASES map. These 8 tests cover all MongoDB-specific
alias normalization paths (connectionString, uri, authSource, replicaSet,
directConnection, connectTimeoutMS, mongo type alias, and canonical passthrough).
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
https://claude.ai/code/session_01AhNUh22SS3cRR9GVNiTcit
anandgupta42 pushed a commit that referenced this pull request Mar 27, 2026
Cover untested CI/CD code path (ALTIMATE_CODE_CONN_* env vars) and new MongoDB
detectAuthMethod branches added in PR #482.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
https://claude.ai/code/session_01Uf1H6t7768cFYAT9AbKSzr
anandgupta42 pushed a commit that referenced this pull request Mar 27, 2026
Cover untested pure functions in the connection registry: detectAuthMethod
MongoDB paths (added in #482) and loadFromEnv parsing via public API.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
https://claude.ai/code/session_016v7ah9WzhYe5veNDx1hh8W
anandgupta42 pushed a commit that referenced this pull request Mar 27, 2026
…, MongoDB auth detection
Cover untested code paths in the connection subsystem: dbt env_var defaults,
adapter type aliases (spark→databricks, trino→postgres), config key skipping,
multi-profile parsing, Docker container-to-config conversion, and the new
MongoDB auth method detection added in #482.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
anandgupta42 pushed a commit that referenced this pull request Mar 27, 2026
…hMethod
Cover two untested areas in the warehouse connection layer:
1. extractSshConfig: zero prior coverage for the function that extracts SSH
tunnel config and validates connection_string incompatibility.
2. detectAuthMethod MongoDB paths: newly added in #482 (MongoDB driver support)
with no test coverage for the type-specific fallback branch.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
https://claude.ai/code/session_01Wr8GYaTQDKpHV1UQDftUJr
anandgupta42 added a commit that referenced this pull request Mar 29, 2026
The mongodb driver (#482) was added to optionalDependencies only,
so `tsgo --noEmit` failed with TS2307 when checking the drivers
package. Adding it to devDependencies ensures types are available
during CI typecheck without making it a runtime requirement.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
anandgupta42 added a commit that referenced this pull request Mar 29, 2026
* feat: plan agent refinement, feature discovery, and telemetry instrumentation
## Plan Agent Improvements
- Two-step plan approach: outline first, confirm, then expand
- Plan refinement loop: edit instead of restart (capped at 5 revisions)
- Approval detection for common phrases ("looks good", "proceed", "lgtm")
- Bug fix: `agent_outcome` telemetry for plan sessions emitting null for
`duration_ms`, `tool_calls`, `generations` — `sessionAgentName` set too late
## Feature Discovery & Progressive Disclosure
- Post-warehouse-connect contextual suggestions (schema, SQL, lineage, PII)
- Progressive: `sql_execute` → `sql_analyze` → `schema_inspect` → `lineage_check`
- dbt auto-detection → recommends `/dbt-develop`, `/dbt-troubleshoot`
- All suggestions try/catch wrapped, never block core flow
## Telemetry
- New `plan_revision` event: revision count + action (refine/approve/reject)
- New `feature_suggestion` event: suggestions shown, type, warehouse
- `skill_used.trigger`: user_command | llm_selected | auto_suggested
- `classifySkillTrigger()` helper
## Tests
- 140 new tests across 4 files, all passing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address CodeRabbit review comments
- Validate `sessionId` before telemetry track in post-connect-suggestions
- Rename shadowed `ctx` to `suggestionCtx` in warehouse-add.ts
- Add rejection detection ("no", "stop", "reject", etc.) to plan revision
action — telemetry now emits "reject" in addition to "approve"/"refine"
- Add `warehouseType` to `trackSuggestions` in sql-analyze and schema-inspect
for telemetry payload consistency
- Use hyphenated skill names in telemetry (`dbt-develop` not `dbt_develop`)
to match user-facing `/dbt-develop` command names
- Derive `suggestionsShown` from `suggestionCtx` to prevent drift
- DRY up event types list in telemetry.test.ts (`ALL_EVENT_TYPES` constant)
- Remove `@ts-nocheck` from plan-skill-telemetry.test.ts
- Add runtime `Telemetry.track()` verification to type-only tests
- Use semantic regex in plan-refinement tests instead of brittle string matches
- Fix trackBlock extraction with generous region window instead of fixed slice
- Remove duplicate regression tests (covered in telemetry.test.ts)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: e2e tests, performance benchmarks, and UX gap fixes
## E2E Integration Tests (41 tests)
- `feature-discovery-e2e.test.ts` (29 tests): Full warehouse-add → suggestions
flow, progressive disclosure chain, plan refinement session, telemetry
event validation with mocked Dispatcher
- `performance-regression.test.ts` (12 tests): 1000x suggestion generation
< 50ms, 10000x progressive lookup < 50ms, 100k phrase detection < 200ms,
output determinism verification
## UX Gap Fixes
- **Suggestion deduplication**: Progressive hints shown at most once per
session per tool via `shownProgressiveSuggestions` Set. Running
`sql_execute` 10 times no longer repeats the same tip.
- **Approval false positives**: "yes, but change X" now correctly classified
as "refine" not "approve". Added `refinementQualifiers` (" but ",
" however ", " except ", " change ", etc.) that override approval detection.
"no" uses `\bno\b` word boundary to avoid matching "know", "notion", etc.
- **Revision cap communication**: When 5 revision cap is hit, a synthetic
message informs the LLM to tell the user. Telemetry tracks "cap_reached".
- **Warehouse add latency**: Suggestion gathering now uses `Promise.all` +
`Promise.race` with 1500ms timeout. Slow schema/dbt checks silently
skipped instead of blocking the response.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: plan layer safety e2e tests (68 tests)
Comprehensive user-perspective tests for the plan refinement changes:
## Phrase Classification (42 tests)
- 14 approval cases ("looks good", "proceed", "lgtm", etc.)
- 12 rejection cases ("no", "stop", "reject", etc.)
- 8 pure refinement cases (feedback without approval/rejection signals)
- 8 tricky edge cases:
- "yes, but change X" → refine (qualifier overrides approval)
- "no, I mean yes" → reject (rejection takes priority)
- "I know this looks good" → approve ("know" ≠ "no" via word boundary)
- Unicode input, multiline, special characters, empty string
## Non-Plan Agent Safety (3 tests)
- Plan variables initialized before loop
- Refinement block guarded by `agent.name === "plan"`
- Plan file detection guarded by agent check
## Session Agent Name Fix (2 tests)
- `sessionAgentName` set before early break conditions
- `agent_outcome` telemetry uses `sessionAgentName`
## Revision Cap (4 tests)
- Cap enforced at >= 5
- Synthetic message communicates limit to LLM
- Telemetry emits "cap_reached"
- Synthetic message doesn't persist to DB
## Adversarial (4 tests)
- 70k char input doesn't crash
- Unicode, special chars, multiline handled
## Import Safety (2 tests)
- post-connect-suggestions is self-contained (no heavy imports)
- Progressive suggestion dedup works correctly
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add mongodb to devDependencies for typecheck resolution
The mongodb driver (#482) was added to optionalDependencies only,
so `tsgo --noEmit` failed with TS2307 when checking the drivers
package. Adding it to devDependencies ensures types are available
during CI typecheck without making it a runtime requirement.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: track suggestion failures in warehouse-add telemetry
Per Surya's review — the catch block in warehouse-add now emits a
`core_failure` event with `error_class: "internal"` and
`input_signature: "post_connect_suggestions"` so we can monitor
how often post-connect suggestions fail and why.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: 125 simulated user scenarios for plan + suggestions
Exercises the real code paths with realistic inputs:
- 84 phrase classification scenarios: approval (20), rejection (24),
refinement (16), qualifier overrides (12), word boundary (12)
- 13 warehouse suggestion configs: 8 warehouse types x indexed/dbt/multi
- 8 progressive disclosure chains: full progression, dedup, interleaved
- 6 revision cap simulations: mixed actions, all rejections, cap behavior
- 5 performance stress: 10k classifications < 500ms, determinism checks
- 10 adversarial: unicode lookalikes, 50KB, SQL injection, null bytes
All 125 pass in 255ms.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: 40 real tool execution simulations with mocked Dispatcher
Spawns actual tool execute() functions (not mocked) with registered
Dispatcher handlers to simulate real user tool invocations:
Warehouse Add (18 scenarios):
- 8 warehouse types with post-connect suggestions
- Schema indexed/not-indexed variations
- Multi-warehouse data_diff suggestion
- Failure modes: add fails, throws, missing type
- Resilience: schema.cache_status fails, warehouse.list fails
- Timeout: slow dispatcher (3s) races against 1.5s timeout
SQL Execute (6 scenarios):
- First call gets suggestion, subsequent calls deduped
- 10 consecutive calls — only first has hint
- Failure and empty result handling
- Blocked query (DROP DATABASE) throws
SQL Analyze (4 scenarios):
- First call suggests schema_inspect, second deduped
- Parse error and analyzer failure handling
Schema Inspect (3 scenarios):
- First call suggests lineage_check, second deduped
- Failure handling
Schema Index (3 scenarios):
- Lists all capabilities on first call
- Dedup on second, failure handling
Full User Journeys (4 scenarios):
- Complete 5-tool chain: warehouse_add → schema_index → sql_execute → sql_analyze → schema_inspect
- 20 repeated queries with dedup verification
- Interleaved tool calls with independent dedup
- All dispatchers failing — warehouse add still succeeds
Performance (2 scenarios):
- Warehouse add < 500ms with fast dispatchers
- 50 consecutive sql_execute < 2s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: document plan refinement, feature discovery, and new telemetry events
- agent-modes.md: Expanded Plan section with two-step workflow (outline
then expand), refinement loop (approve/refine/reject), 5-revision cap,
and example conversation
- telemetry.md: Added plan_revision and feature_suggestion events,
updated skill_used with trigger field
- warehouses.md: Added "Post-Connection Suggestions" section covering
progressive disclosure chain and once-per-session dedup
- getting-started.md: Added feature suggestions mention after /discover
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: replace mock.module() with spyOn to prevent cross-file test pollution
Root cause of 112 CI failures: three test files used Bun's
mock.module() to replace the Telemetry module with a partial mock.
mock.module() is process-global in Bun — it persisted across ALL
test files, causing Telemetry functions (categorizeToolName,
classifyError, bucketCount, computeInputSignature, maskArgs, etc.)
to be undefined for any test file loaded after the mock.
Fix: replaced mock.module() with spyOn() + afterEach(mock.restore())
in post-connect-suggestions.test.ts, performance-regression.test.ts,
and feature-discovery-e2e.test.ts. spyOn is per-function and properly
cleaned up between tests.
Result: 5740 pass, 0 fail (was 112 fail) across 285 files.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: reset dedup state in tests + replace passwords with fake values
- post-connect-suggestions.test.ts: add resetShownSuggestions() in
beforeEach to prevent cross-file dedup state from causing the
"after sql_execute suggests sql_analyze" test to fail in CI
- connections.test.ts: replace "secret", "pw123", "ssh-pw",
"access-token-123" with obviously fake test values to resolve
GitGuardian false positives
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: replace all credential-like test values for GitGuardian
Replace remaining flagged values: "passphrase", "oauth-token",
"client-secret", "my_secret", "my-passphrase", dapi_secret with
obviously fake test-prefixed placeholders.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitaicoderabbitaiBot mentioned this pull request Mar 30, 2026
6 tasks
kulvirgit pushed a commit that referenced this pull request Mar 30, 2026
* feat: add MongoDB driver support
Add MongoDB as the 11th supported database driver, enabling document
database operations via the existing `Connector` interface.
- New driver at `packages/drivers/src/mongodb.ts` supporting:
- Full MQL command set: find, aggregate, CRUD, indexes, collection mgmt
- Cross-database queries via per-query `database` field
- BSON type serialization (ObjectId, Decimal128, Long, UUID, Binary, Date)
- Schema introspection via document sampling with field type inference
- Connection string URI and host/port/user/password auth
- `authorizedDatabases` fallback for restricted-privilege users
- Registration in driver index, config normalizer (with `mongo`/`mongodb` aliases), and connection registry
- CI: MongoDB 7.0 service in driver-e2e workflow with health checks
- 90 E2E tests including:
- CRUD operations, aggregation pipelines, schema introspection
- Cross-database operations, index management, collection lifecycle
- Adversarial tests: deeply nested docs, special characters, heterogeneous
collections, concurrent operations, large documents, numeric edge cases
Closes#480
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address multi-model code review findings for MongoDB driver
Fixes from 6-model consensus review (Claude, GPT 5.2 Codex, Gemini 3.1
Pro, Kimi K2.5, MiniMax M2.5, GLM-5):
- Cap user-specified `limit` against `effectiveLimit` to prevent OOM
from unbounded queries (flagged by Gemini)
- Add `ping` command for connection testing instead of querying
`system.version` which may not be accessible (flagged by Gemini, GLM-5)
- Add `e.code === 26` fallback for `dropCollection` error handling
across MongoDB versions (flagged by GLM-5)
- Fix misleading docstring on `extractFields` that claimed dot-notation
expansion (flagged by Gemini)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address CodeRabbit findings and update docs for MongoDB driver
CodeRabbit review fixes:
- Use `...COMMON_ALIASES` spread in `MONGODB_ALIASES` for consistency
with other drivers (normalize.ts)
- Scan entire aggregate pipeline for `$limit` instead of only last
stage; also skip auto-limit for `$out`/`$merge` write pipelines
- Keep `mongodb` at `^6.0.0` (NOT upgrading to v7): v7 drops Node 16/18
support and has many breaking changes; v6.21.0 is actively maintained
and supports MongoDB server 3.6-8.0
Additional review fixes:
- Include database name in URI when building from individual config
fields for correct auth-source resolution (GLM-5)
- Add security comment about credential exposure in URI (Kimi K2.5)
Documentation updates:
- `docs/docs/drivers.md`: add MongoDB to support matrix (11 databases),
install section, auth methods, auto-discovery
- `docs/docs/configure/warehouses.md`: add MongoDB configuration section
with connection string and field-based examples, server compatibility
- `docs/docs/data-engineering/tools/warehouse-tools.md`: add MongoDB to
Docker discovery and env var detection
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* style: format MongoDB driver files with Prettier
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: cap aggregate `$limit` and serialize `distinct` values (CodeRabbit)
- Cap user-specified `$limit` in aggregate pipelines against
`effectiveLimit` to prevent OOM, matching the `find` command behavior
- Serialize `distinct` return values through `serializeValue()` for
consistent BSON type handling across find/aggregate/distinct
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
kulvirgit pushed a commit that referenced this pull request Mar 30, 2026
* feat: plan agent refinement, feature discovery, and telemetry instrumentation
## Plan Agent Improvements
- Two-step plan approach: outline first, confirm, then expand
- Plan refinement loop: edit instead of restart (capped at 5 revisions)
- Approval detection for common phrases ("looks good", "proceed", "lgtm")
- Bug fix: `agent_outcome` telemetry for plan sessions emitting null for
`duration_ms`, `tool_calls`, `generations` — `sessionAgentName` set too late
## Feature Discovery & Progressive Disclosure
- Post-warehouse-connect contextual suggestions (schema, SQL, lineage, PII)
- Progressive: `sql_execute` → `sql_analyze` → `schema_inspect` → `lineage_check`
- dbt auto-detection → recommends `/dbt-develop`, `/dbt-troubleshoot`
- All suggestions try/catch wrapped, never block core flow
## Telemetry
- New `plan_revision` event: revision count + action (refine/approve/reject)
- New `feature_suggestion` event: suggestions shown, type, warehouse
- `skill_used.trigger`: user_command | llm_selected | auto_suggested
- `classifySkillTrigger()` helper
## Tests
- 140 new tests across 4 files, all passing
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: address CodeRabbit review comments
- Validate `sessionId` before telemetry track in post-connect-suggestions
- Rename shadowed `ctx` to `suggestionCtx` in warehouse-add.ts
- Add rejection detection ("no", "stop", "reject", etc.) to plan revision
action — telemetry now emits "reject" in addition to "approve"/"refine"
- Add `warehouseType` to `trackSuggestions` in sql-analyze and schema-inspect
for telemetry payload consistency
- Use hyphenated skill names in telemetry (`dbt-develop` not `dbt_develop`)
to match user-facing `/dbt-develop` command names
- Derive `suggestionsShown` from `suggestionCtx` to prevent drift
- DRY up event types list in telemetry.test.ts (`ALL_EVENT_TYPES` constant)
- Remove `@ts-nocheck` from plan-skill-telemetry.test.ts
- Add runtime `Telemetry.track()` verification to type-only tests
- Use semantic regex in plan-refinement tests instead of brittle string matches
- Fix trackBlock extraction with generous region window instead of fixed slice
- Remove duplicate regression tests (covered in telemetry.test.ts)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* feat: e2e tests, performance benchmarks, and UX gap fixes
## E2E Integration Tests (41 tests)
- `feature-discovery-e2e.test.ts` (29 tests): Full warehouse-add → suggestions
flow, progressive disclosure chain, plan refinement session, telemetry
event validation with mocked Dispatcher
- `performance-regression.test.ts` (12 tests): 1000x suggestion generation
< 50ms, 10000x progressive lookup < 50ms, 100k phrase detection < 200ms,
output determinism verification
## UX Gap Fixes
- **Suggestion deduplication**: Progressive hints shown at most once per
session per tool via `shownProgressiveSuggestions` Set. Running
`sql_execute` 10 times no longer repeats the same tip.
- **Approval false positives**: "yes, but change X" now correctly classified
as "refine" not "approve". Added `refinementQualifiers` (" but ",
" however ", " except ", " change ", etc.) that override approval detection.
"no" uses `\bno\b` word boundary to avoid matching "know", "notion", etc.
- **Revision cap communication**: When 5 revision cap is hit, a synthetic
message informs the LLM to tell the user. Telemetry tracks "cap_reached".
- **Warehouse add latency**: Suggestion gathering now uses `Promise.all` +
`Promise.race` with 1500ms timeout. Slow schema/dbt checks silently
skipped instead of blocking the response.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: plan layer safety e2e tests (68 tests)
Comprehensive user-perspective tests for the plan refinement changes:
## Phrase Classification (42 tests)
- 14 approval cases ("looks good", "proceed", "lgtm", etc.)
- 12 rejection cases ("no", "stop", "reject", etc.)
- 8 pure refinement cases (feedback without approval/rejection signals)
- 8 tricky edge cases:
- "yes, but change X" → refine (qualifier overrides approval)
- "no, I mean yes" → reject (rejection takes priority)
- "I know this looks good" → approve ("know" ≠ "no" via word boundary)
- Unicode input, multiline, special characters, empty string
## Non-Plan Agent Safety (3 tests)
- Plan variables initialized before loop
- Refinement block guarded by `agent.name === "plan"`
- Plan file detection guarded by agent check
## Session Agent Name Fix (2 tests)
- `sessionAgentName` set before early break conditions
- `agent_outcome` telemetry uses `sessionAgentName`
## Revision Cap (4 tests)
- Cap enforced at >= 5
- Synthetic message communicates limit to LLM
- Telemetry emits "cap_reached"
- Synthetic message doesn't persist to DB
## Adversarial (4 tests)
- 70k char input doesn't crash
- Unicode, special chars, multiline handled
## Import Safety (2 tests)
- post-connect-suggestions is self-contained (no heavy imports)
- Progressive suggestion dedup works correctly
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: add mongodb to devDependencies for typecheck resolution
The mongodb driver (#482) was added to optionalDependencies only,
so `tsgo --noEmit` failed with TS2307 when checking the drivers
package. Adding it to devDependencies ensures types are available
during CI typecheck without making it a runtime requirement.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: track suggestion failures in warehouse-add telemetry
Per Surya's review — the catch block in warehouse-add now emits a
`core_failure` event with `error_class: "internal"` and
`input_signature: "post_connect_suggestions"` so we can monitor
how often post-connect suggestions fail and why.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: 125 simulated user scenarios for plan + suggestions
Exercises the real code paths with realistic inputs:
- 84 phrase classification scenarios: approval (20), rejection (24),
refinement (16), qualifier overrides (12), word boundary (12)
- 13 warehouse suggestion configs: 8 warehouse types x indexed/dbt/multi
- 8 progressive disclosure chains: full progression, dedup, interleaved
- 6 revision cap simulations: mixed actions, all rejections, cap behavior
- 5 performance stress: 10k classifications < 500ms, determinism checks
- 10 adversarial: unicode lookalikes, 50KB, SQL injection, null bytes
All 125 pass in 255ms.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* test: 40 real tool execution simulations with mocked Dispatcher
Spawns actual tool execute() functions (not mocked) with registered
Dispatcher handlers to simulate real user tool invocations:
Warehouse Add (18 scenarios):
- 8 warehouse types with post-connect suggestions
- Schema indexed/not-indexed variations
- Multi-warehouse data_diff suggestion
- Failure modes: add fails, throws, missing type
- Resilience: schema.cache_status fails, warehouse.list fails
- Timeout: slow dispatcher (3s) races against 1.5s timeout
SQL Execute (6 scenarios):
- First call gets suggestion, subsequent calls deduped
- 10 consecutive calls — only first has hint
- Failure and empty result handling
- Blocked query (DROP DATABASE) throws
SQL Analyze (4 scenarios):
- First call suggests schema_inspect, second deduped
- Parse error and analyzer failure handling
Schema Inspect (3 scenarios):
- First call suggests lineage_check, second deduped
- Failure handling
Schema Index (3 scenarios):
- Lists all capabilities on first call
- Dedup on second, failure handling
Full User Journeys (4 scenarios):
- Complete 5-tool chain: warehouse_add → schema_index → sql_execute → sql_analyze → schema_inspect
- 20 repeated queries with dedup verification
- Interleaved tool calls with independent dedup
- All dispatchers failing — warehouse add still succeeds
Performance (2 scenarios):
- Warehouse add < 500ms with fast dispatchers
- 50 consecutive sql_execute < 2s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* docs: document plan refinement, feature discovery, and new telemetry events
- agent-modes.md: Expanded Plan section with two-step workflow (outline
then expand), refinement loop (approve/refine/reject), 5-revision cap,
and example conversation
- telemetry.md: Added plan_revision and feature_suggestion events,
updated skill_used with trigger field
- warehouses.md: Added "Post-Connection Suggestions" section covering
progressive disclosure chain and once-per-session dedup
- getting-started.md: Added feature suggestions mention after /discover
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: replace mock.module() with spyOn to prevent cross-file test pollution
Root cause of 112 CI failures: three test files used Bun's
mock.module() to replace the Telemetry module with a partial mock.
mock.module() is process-global in Bun — it persisted across ALL
test files, causing Telemetry functions (categorizeToolName,
classifyError, bucketCount, computeInputSignature, maskArgs, etc.)
to be undefined for any test file loaded after the mock.
Fix: replaced mock.module() with spyOn() + afterEach(mock.restore())
in post-connect-suggestions.test.ts, performance-regression.test.ts,
and feature-discovery-e2e.test.ts. spyOn is per-function and properly
cleaned up between tests.
Result: 5740 pass, 0 fail (was 112 fail) across 285 files.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: reset dedup state in tests + replace passwords with fake values
- post-connect-suggestions.test.ts: add resetShownSuggestions() in
beforeEach to prevent cross-file dedup state from causing the
"after sql_execute suggests sql_analyze" test to fail in CI
- connections.test.ts: replace "secret", "pw123", "ssh-pw",
"access-token-123" with obviously fake test values to resolve
GitGuardian false positives
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
* fix: replace all credential-like test values for GitGuardian
Replace remaining flagged values: "passphrase", "oauth-token",
"client-secret", "my_secret", "my-passphrase", dapi_secret with
obviously fake test-prefixed placeholders.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add MongoDB driver support feat: add MongoDB driver support

1 participant

@anandgupta42