feat(tool): add tool registry persistence #279

Closed
opened 2026-02-22 23:40:50 +00:00 by freemo · 1 comment
Owner

Metadata

  • Commit: feat(tool): add tool registry persistence
  • Branch: feature/m3-tool-registry

Subtasks

  • Add DB tables for tools, tool_resource_bindings, and validation_attachments with resource-scoped attachments (resource_id, validation_name, mode, created_at) and indexes on tool name/type + resource_id. Migration: alembic/versions/c1_001_tool_registry_tables.py (depends on b1_001_resource_registry). 3 tables, 7 indexes, 3 CHECK constraints, 3 FKs including self-referential wraps.
  • Implement ToolRegistryRepository (5 methods: create/get_by_name/list_all/update/delete) + ValidationAttachmentRepository (4 methods: attach/detach/list_for_resource/get_by_id) and ToolRegistryService (8 methods) with attach/detach by resource and mode validation (required/informational). Custom errors: DuplicateToolError, ToolInUseError.
  • Update docs/reference/database_schema.md with 3 new table sections (tools, tool_resource_bindings, validation_attachments), updated ER diagram, migration chain, and source locations.
  • Tests (Behave): Add features/tool_registry.feature (27 scenarios across 7 groups: create/read/list/update/delete/attachments/service) with features/steps/tool_registry_steps.py (598 lines).
  • Tests (Robot): Add robot/tool_registry.robot (4 integration tests: register-and-get, list-filter, attach-detach, duplicate-reject) with robot/helper_tool_registry.py (123 lines).
  • Tests (ASV): Add benchmarks/tool_registry_bench.py (3 ASV suites, 7 benchmarks: ORM construction, CRUD operations, attachment operations).
  • Run nox (all default sessions, including benchmark), fix any errors if needed ensuring nox passes.
  • 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%.
  • 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%.

Section: ### Section 5: Actors, Skills & Tool Execution [WORKSTREAM C - Aditya Lead]
Status: Completed

## Metadata - **Commit**: `feat(tool): add tool registry persistence` - **Branch**: `feature/m3-tool-registry` ## Subtasks - [x] Add DB tables for `tools`, `tool_resource_bindings`, and `validation_attachments` with resource-scoped attachments (`resource_id`, `validation_name`, `mode`, `created_at`) and indexes on tool name/type + resource_id. Migration: `alembic/versions/c1_001_tool_registry_tables.py` (depends on `b1_001_resource_registry`). 3 tables, 7 indexes, 3 CHECK constraints, 3 FKs including self-referential `wraps`. - [x] Implement `ToolRegistryRepository` (5 methods: create/get_by_name/list_all/update/delete) + `ValidationAttachmentRepository` (4 methods: attach/detach/list_for_resource/get_by_id) and `ToolRegistryService` (8 methods) with attach/detach by resource and mode validation (required/informational). Custom errors: `DuplicateToolError`, `ToolInUseError`. - [x] Update `docs/reference/database_schema.md` with 3 new table sections (tools, tool_resource_bindings, validation_attachments), updated ER diagram, migration chain, and source locations. - [x] Tests (Behave): Add `features/tool_registry.feature` (27 scenarios across 7 groups: create/read/list/update/delete/attachments/service) with `features/steps/tool_registry_steps.py` (598 lines). - [x] Tests (Robot): Add `robot/tool_registry.robot` (4 integration tests: register-and-get, list-filter, attach-detach, duplicate-reject) with `robot/helper_tool_registry.py` (123 lines). - [x] Tests (ASV): Add `benchmarks/tool_registry_bench.py` (3 ASV suites, 7 benchmarks: ORM construction, CRUD operations, attachment operations). - [x] Run `nox` (all default sessions, including benchmark), fix any errors if needed ensuring nox passes. - [x] 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%. - [x] 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%. **Section**: ### Section 5: Actors, Skills & Tool Execution [WORKSTREAM C - Aditya Lead] **Status**: Completed
freemo added this to the v3.1.0 milestone 2026-02-22 23:40:50 +00:00
Author
Owner

Implementation Notes — C1.tool.registry: Tool Registry Persistence

2026-02-14: Stage C1.tool.registry Complete - Tool Registry Persistence

  • Created Alembic migration with 3 tables: tools, tool_resource_bindings, validation_attachments.
  • Created ToolRegistryRepository (5 methods), ValidationAttachmentRepository (4 methods), ToolRegistryService (8 methods).
  • Key decision: ToolModel.to_domain() returns a dict (not a domain object) to decouple persistence from domain model until full integration is complete.
  • Key decision: ToolRegistryRepository.delete() pre-checks for active ValidationAttachmentModel rows before allowing deletion.
  • Key decision: Validation attachments are resource-scoped with optional project_name and plan_id narrowing.

(Migrated from docs/implementation-notes.md)

## Implementation Notes — C1.tool.registry: Tool Registry Persistence **2026-02-14**: Stage C1.tool.registry Complete - Tool Registry Persistence - Created Alembic migration with 3 tables: `tools`, `tool_resource_bindings`, `validation_attachments`. - Created `ToolRegistryRepository` (5 methods), `ValidationAttachmentRepository` (4 methods), `ToolRegistryService` (8 methods). - Key decision: `ToolModel.to_domain()` returns a dict (not a domain object) to decouple persistence from domain model until full integration is complete. - Key decision: `ToolRegistryRepository.delete()` pre-checks for active `ValidationAttachmentModel` rows before allowing deletion. - Key decision: Validation attachments are resource-scoped with optional project_name and plan_id narrowing. *(Migrated from `docs/implementation-notes.md`)*
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".

No due date set.

Blocks
#354 Epic: Actor & Skill Schema + CLI (C0)
cleveragents/cleveragents-core
Depends on
#91 ten-branches
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#279
No description provided.