feat(resource): add database resources #342

Closed
opened 2026-02-22 23:41:26 +00:00 by freemo · 2 comments
Owner

Metadata

  • Commit Message: feat(resource): add database resources
  • Branch: feature/m7-post-resource-db

Background

Database resource types (postgres, mysql, sqlite, duckdb) are defined with connection arguments and auth handling. Sandbox strategy uses transaction wrappers and read-only toggles. Connection validation includes safe error messaging that masks credentials.

Acceptance Criteria

  • Add database resource types (postgres, mysql, sqlite, duckdb) with connection args and auth handling.
  • Implement sandbox strategy using transaction wrappers and read-only toggles.
  • Add connection validation and safe error messaging (mask credentials in logs).
  • Document database resource configuration and supported auth options.

Definition of Done

This issue is complete when:

  • All subtasks below are completed and checked off.
  • A Git commit is created where the first line of the commit message matches
    the Commit Message in Metadata exactly, followed by a blank line, then
    additional lines providing relevant details about the implementation. The
    commit body should be appropriate in size for a commit message and relatively
    complete in describing what was done.
  • The commit is pushed to the remote on the branch matching the Branch in
    Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and
    merged before this issue is marked done.

Subtasks

  • Add database resource types (postgres, mysql, sqlite, duckdb) with connection args and auth handling.
  • Implement sandbox strategy using transaction wrappers and read-only toggles.
  • Add connection validation and safe error messaging (mask credentials in logs).
  • Document database resource configuration and supported auth options.
  • Tests (Behave): Add database resource scenarios (connection validation, read-only enforcement).
  • Tests (Robot): Add database resource integration tests (local sqlite/duckdb only).
  • Tests (ASV): Add benchmarks/db_resource_bench.py for resource registration baseline.
  • Verify coverage >=97% via nox -s coverage_report. If coverage is <97% then review the current unit test coverage report at build/coverage.xml and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improves coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun nox -s coverage_report to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%.
  • Run nox (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across entire code base, do not ignore any failure even if it seems unrelated to this commit, fix it.

Section: ### Section 18: Deferred Work
Status: Open

## Metadata - **Commit Message**: `feat(resource): add database resources` - **Branch**: `feature/m7-post-resource-db` ## Background Database resource types (postgres, mysql, sqlite, duckdb) are defined with connection arguments and auth handling. Sandbox strategy uses transaction wrappers and read-only toggles. Connection validation includes safe error messaging that masks credentials. ## Acceptance Criteria - [ ] Add database resource types (postgres, mysql, sqlite, duckdb) with connection args and auth handling. - [ ] Implement sandbox strategy using transaction wrappers and read-only toggles. - [ ] Add connection validation and safe error messaging (mask credentials in logs). - [ ] Document database resource configuration and supported auth options. ## Definition of Done This issue is complete when: - All subtasks below are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. The commit body should be appropriate in size for a commit message and relatively complete in describing what was done. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. ## Subtasks - [ ] Add database resource types (postgres, mysql, sqlite, duckdb) with connection args and auth handling. - [ ] Implement sandbox strategy using transaction wrappers and read-only toggles. - [ ] Add connection validation and safe error messaging (mask credentials in logs). - [ ] Document database resource configuration and supported auth options. - [ ] Tests (Behave): Add database resource scenarios (connection validation, read-only enforcement). - [ ] Tests (Robot): Add database resource integration tests (local sqlite/duckdb only). - [ ] Tests (ASV): Add `benchmarks/db_resource_bench.py` for resource registration baseline. - [ ] Verify coverage >=97% via `nox -s coverage_report`. If coverage is <97% then review the current unit test coverage report at `build/coverage.xml` and use it to write new Behave based unit tests to improve code coverage. Specifically, write Behave style unit tests that are descriptively named and specifically improves coverage on whichever file has the most uncovered lines by writing tests that will target the uncovered lines in the report. Once that is done rerun `nox -s coverage_report` to verify all tests pass and coverage is above >=97%. Only mark this as complete once coverage is >=97%, if not repeat this task as many times as is needed until coverage reaches >=97%. - [ ] Run `nox` (all default sessions, including benchmark), fix any errors if needed ensuring nox passes across **entire** code base, do not ignore any failure even if it seems unrelated to this commit, fix it. **Section**: ### Section 18: Deferred Work **Status**: Open
freemo added this to the (deleted) milestone 2026-02-22 23:41:26 +00:00
freemo modified the milestone from (deleted) to v3.6.0 2026-02-23 00:07:04 +00:00
Author
Owner

Expected completion updated (Day 15 rebaseline): Day 52 / 2026-04-01 (previously Day 47 / 2026-03-27)

**Expected completion updated (Day 15 rebaseline):** Day 52 / 2026-04-01 (previously Day 47 / 2026-03-27)
freemo added the due date 2026-03-19 2026-02-23 18:42:01 +00:00
freemo self-assigned this 2026-02-24 21:53:38 +00:00
Author
Owner

PR #674 submitted for review

Branch: feature/m7-post-resource-db
PR: #674

Summary

Implemented database resource types (postgres, mysql, sqlite, duckdb) with transaction-based sandbox strategy.

New components:

  • DatabaseResourceHandler — 4 database type definitions with connection argument resolution (including env var fallback), connection validation with credential masking
  • TransactionSandbox — Implements Sandbox protocol with SQLite backend (BEGIN/ROLLBACK/COMMIT), read-only toggle via PRAGMA, and execute() convenience method
  • Wired into SandboxFactorytransaction_rollback strategy now produces TransactionSandbox instances
  • Registered 4 DB types (postgres, mysql, sqlite, duckdb) in bootstrap_builtin_types() and BUILTIN_NAMES

Tests: 35 Behave BDD scenarios + 8 Robot Framework integration tests + ASV benchmarks

Nox results: All stages pass — lint ✓, typecheck (0 errors) ✓, unit_tests (9764 passed) ✓, integration_tests (1353 passed) ✓, coverage (98.44%) ✓

## PR #674 submitted for review **Branch:** `feature/m7-post-resource-db` **PR:** https://git.cleverthis.com/cleveragents/cleveragents-core/pulls/674 ### Summary Implemented database resource types (postgres, mysql, sqlite, duckdb) with transaction-based sandbox strategy. **New components:** - `DatabaseResourceHandler` — 4 database type definitions with connection argument resolution (including env var fallback), connection validation with credential masking - `TransactionSandbox` — Implements Sandbox protocol with SQLite backend (BEGIN/ROLLBACK/COMMIT), read-only toggle via PRAGMA, and `execute()` convenience method - Wired into `SandboxFactory` — `transaction_rollback` strategy now produces `TransactionSandbox` instances - Registered 4 DB types (`postgres`, `mysql`, `sqlite`, `duckdb`) in `bootstrap_builtin_types()` and `BUILTIN_NAMES` **Tests:** 35 Behave BDD scenarios + 8 Robot Framework integration tests + ASV benchmarks **Nox results:** All stages pass — lint ✓, typecheck (0 errors) ✓, unit_tests (9764 passed) ✓, integration_tests (1353 passed) ✓, coverage (98.44%) ✓
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

2026-03-19

Blocks
#398 Epic: Post-MVP Resources
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#342
No description provided.