feat(resource): implement DatabaseResourceHandler CRUD and checkpoint methods #1241

Closed
opened 2026-04-01 14:04:30 +00:00 by hamza.khyari · 1 comment
Member

Metadata

  • Commit Message: feat(resource): implement DatabaseResourceHandler CRUD and checkpoint methods
  • Branch: feature/database-handler-completion
  • Type: Feature
  • Priority: Medium
  • MoSCoW: Should have
  • Points: 8
  • Milestone: v3.6.0

Background and Context

Epic #825 (ResourceHandler Protocol Completion) requires all handler types to implement the full protocol. DatabaseResourceHandler currently only implements content_hash(). The original tickets #827 and #836 explicitly require database implementations:

  • #827 AC: "read() implemented for database (query)" and "write() implemented for database (execute)"
  • #836 AC: "create_checkpoint() implemented for database (savepoint)" and "rollback_to() implemented for database (rollback to savepoint)"

These were left as NotImplementedError stubs in the merged PRs.

Expected Behavior

DatabaseResourceHandler supports reading schema/data via SQL queries, writing via SQL execution, deleting tables, listing database objects, comparing schemas, creating savepoint checkpoints, and rolling back to savepoints. SQLite is the primary implementation target; remote databases (PostgreSQL, MySQL) return graceful fallbacks.

Acceptance Criteria

  • read() implemented — SQLite: query sqlite_master schema; remote: connection-info summary
  • write() implemented — SQLite: execute SQL statement; remote: not-supported result
  • delete() implemented — SQLite: DROP TABLE IF EXISTS; remote: not-supported result
  • list_children() implemented — SQLite: list tables/views from sqlite_master
  • diff() implemented — compare schemas via content hash
  • create_checkpoint() implemented — SQLite: SAVEPOINT; remote: content hash fallback
  • rollback_to() implemented — SQLite: ROLLBACK TO SAVEPOINT; remote: not-supported
  • All methods handle errors gracefully (no unhandled exceptions)

Definition of Done

This issue is complete when:

  • All subtasks above 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.
  • 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

  • Implement read() for DatabaseResourceHandler (SQLite schema query + remote fallback)
  • Implement write() for DatabaseResourceHandler (SQLite execute + remote fallback)
  • Implement delete() for DatabaseResourceHandler (SQLite DROP TABLE + remote fallback)
  • Implement list_children() for DatabaseResourceHandler (SQLite tables/views)
  • Implement diff() for DatabaseResourceHandler (schema hash comparison)
  • Implement create_checkpoint() for DatabaseResourceHandler (SQLite SAVEPOINT)
  • Implement rollback_to() for DatabaseResourceHandler (SQLite ROLLBACK TO SAVEPOINT)
  • Tests (Behave): Add scenarios for each method with SQLite database
  • Tests (Robot): Add integration test for checkpoint → modify → rollback cycle
  • Verify coverage >= 97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors
## Metadata - **Commit Message**: `feat(resource): implement DatabaseResourceHandler CRUD and checkpoint methods` - **Branch**: `feature/database-handler-completion` - **Type**: Feature - **Priority**: Medium - **MoSCoW**: Should have - **Points**: 8 - **Milestone**: v3.6.0 ## Background and Context Epic #825 (ResourceHandler Protocol Completion) requires all handler types to implement the full protocol. `DatabaseResourceHandler` currently only implements `content_hash()`. The original tickets #827 and #836 explicitly require database implementations: - #827 AC: "`read()` implemented for database (query)" and "`write()` implemented for database (execute)" - #836 AC: "`create_checkpoint()` implemented for database (savepoint)" and "`rollback_to()` implemented for database (rollback to savepoint)" These were left as `NotImplementedError` stubs in the merged PRs. ## Expected Behavior `DatabaseResourceHandler` supports reading schema/data via SQL queries, writing via SQL execution, deleting tables, listing database objects, comparing schemas, creating savepoint checkpoints, and rolling back to savepoints. SQLite is the primary implementation target; remote databases (PostgreSQL, MySQL) return graceful fallbacks. ## Acceptance Criteria - [x] `read()` implemented — SQLite: query `sqlite_master` schema; remote: connection-info summary - [x] `write()` implemented — SQLite: execute SQL statement; remote: not-supported result - [x] `delete()` implemented — SQLite: `DROP TABLE IF EXISTS`; remote: not-supported result - [x] `list_children()` implemented — SQLite: list tables/views from `sqlite_master` - [x] `diff()` implemented — compare schemas via content hash - [x] `create_checkpoint()` implemented — SQLite: `SAVEPOINT`; remote: content hash fallback - [x] `rollback_to()` implemented — SQLite: `ROLLBACK TO SAVEPOINT`; remote: not-supported - [x] All methods handle errors gracefully (no unhandled exceptions) ## Definition of Done This issue is complete when: - All subtasks above 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. - 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 - [x] Implement `read()` for DatabaseResourceHandler (SQLite schema query + remote fallback) - [x] Implement `write()` for DatabaseResourceHandler (SQLite execute + remote fallback) - [x] Implement `delete()` for DatabaseResourceHandler (SQLite DROP TABLE + remote fallback) - [x] Implement `list_children()` for DatabaseResourceHandler (SQLite tables/views) - [x] Implement `diff()` for DatabaseResourceHandler (schema hash comparison) - [x] Implement `create_checkpoint()` for DatabaseResourceHandler (SQLite SAVEPOINT) - [x] Implement `rollback_to()` for DatabaseResourceHandler (SQLite ROLLBACK TO SAVEPOINT) - [x] Tests (Behave): Add scenarios for each method with SQLite database - [ ] Tests (Robot): Add integration test for checkpoint → modify → rollback cycle - [x] Verify coverage >= 97% via `nox -s coverage_report` - [x] Run `nox` (all default sessions), fix any errors
hamza.khyari added this to the v3.6.0 milestone 2026-04-01 14:04:30 +00:00
freemo self-assigned this 2026-04-02 06:13:58 +00:00
Owner

PR #1293 reviewed, approved, and merged.

All 7 CRUD and checkpoint methods on DatabaseResourceHandler are now implemented:

  • read(), write(), delete(), list_children(), diff(), create_checkpoint(), rollback_to()

Comprehensive Behave BDD tests (30+ scenarios) are included. Minor follow-up items noted in the PR review (import placement, file size, Robot integration test).

PR #1293 reviewed, approved, and merged. All 7 CRUD and checkpoint methods on `DatabaseResourceHandler` are now implemented: - `read()`, `write()`, `delete()`, `list_children()`, `diff()`, `create_checkpoint()`, `rollback_to()` Comprehensive Behave BDD tests (30+ scenarios) are included. Minor follow-up items noted in the PR review (import placement, file size, Robot integration test).
Sign in to join this conversation.
No milestone
No project
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
Reference
cleveragents/cleveragents-core#1241
No description provided.