agents resource add fs-directory should not cause an error. #523

Closed
opened 2026-03-03 01:31:27 +00:00 by brent.edwards · 1 comment
Member

Metadata

  • Commit Message: fix(resource): call bootstrap_builtin_types during initialization
  • Branch: feature/m3-fix-resource-bootstrap

Background and Context

agents resource add fs-directory local/source --path /home/devuser/python fails with "Resource type not found: fs-directory". The root cause is that bootstrap_builtin_types() in src/cleveragents/application/services/resource_registry_service.py:151 is never called during initialization. The built-in resource types (fs-directory, git-checkout) are defined in _BUILTIN_TYPES (lines 66-124) but never seeded into the database.

The init_command (cli/commands/project.py:176) calls project_service.initialize_project(), which calls unit_of_work.init_database() to create tables — but never bootstraps the built-in resource types into them.

This bug shares the same root cause as #524 (git-checkout also not found). A single fix will resolve both.

Expected Behavior

After agents init, the built-in resource types (fs-directory, git-checkout, and any others in _BUILTIN_TYPES) are seeded into the database and available for agents resource add.

Acceptance Criteria

  • agents resource add fs-directory local/test --path /tmp/test succeeds after agents init.
  • bootstrap_builtin_types() is called during the initialization path.
  • All built-in resource types from _BUILTIN_TYPES are present in the database after init.
  • All failing tests from #537 now pass.
  • This fix also resolves #524 (git-checkout type not found).

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 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

  • Code [freemo]: Add a call to resource_registry_service.bootstrap_builtin_types() in the initialization path (either in init_command, initialize_project(), or as a post-init_database() hook) so that built-in resource types are seeded on first run.
  • Code [freemo]: Ensure bootstrap_builtin_types() is idempotent — calling it multiple times does not duplicate types.
  • Code [freemo]: Verify that both fs-directory and git-checkout (and any other _BUILTIN_TYPES) are present in the database after initialization.
  • Docs [freemo]: Add a comment in the initialization code explaining that built-in types must be bootstrapped after schema creation.
  • Tests (Behave) [freemo]: Verify that all Behave scenarios from #537 now pass with the fix applied.
  • Tests (Robot) [freemo]: Verify the Robot smoke test from #537 passes.
  • Tests (ASV) [freemo]: Verify the ASV benchmark from #537 runs correctly.
  • Quality [freemo]: 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 improve 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%.
  • Quality [freemo]: 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.

Parent: #401
Blocked by: #537

## Metadata - **Commit Message**: `fix(resource): call bootstrap_builtin_types during initialization` - **Branch**: `feature/m3-fix-resource-bootstrap` ## Background and Context `agents resource add fs-directory local/source --path /home/devuser/python` fails with "Resource type not found: fs-directory". The root cause is that `bootstrap_builtin_types()` in `src/cleveragents/application/services/resource_registry_service.py:151` is never called during initialization. The built-in resource types (`fs-directory`, `git-checkout`) are defined in `_BUILTIN_TYPES` (lines 66-124) but never seeded into the database. The `init_command` (`cli/commands/project.py:176`) calls `project_service.initialize_project()`, which calls `unit_of_work.init_database()` to create tables — but never bootstraps the built-in resource types into them. This bug shares the same root cause as #524 (`git-checkout` also not found). A single fix will resolve both. ## Expected Behavior After `agents init`, the built-in resource types (`fs-directory`, `git-checkout`, and any others in `_BUILTIN_TYPES`) are seeded into the database and available for `agents resource add`. ## Acceptance Criteria - [ ] `agents resource add fs-directory local/test --path /tmp/test` succeeds after `agents init`. - [ ] `bootstrap_builtin_types()` is called during the initialization path. - [ ] All built-in resource types from `_BUILTIN_TYPES` are present in the database after init. - [ ] All failing tests from #537 now pass. - [ ] This fix also resolves #524 (git-checkout type not found). ## 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 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 - [ ] Code [freemo]: Add a call to `resource_registry_service.bootstrap_builtin_types()` in the initialization path (either in `init_command`, `initialize_project()`, or as a post-`init_database()` hook) so that built-in resource types are seeded on first run. - [ ] Code [freemo]: Ensure `bootstrap_builtin_types()` is idempotent — calling it multiple times does not duplicate types. - [ ] Code [freemo]: Verify that both `fs-directory` and `git-checkout` (and any other `_BUILTIN_TYPES`) are present in the database after initialization. - [ ] Docs [freemo]: Add a comment in the initialization code explaining that built-in types must be bootstrapped after schema creation. - [ ] Tests (Behave) [freemo]: Verify that all Behave scenarios from #537 now pass with the fix applied. - [ ] Tests (Robot) [freemo]: Verify the Robot smoke test from #537 passes. - [ ] Tests (ASV) [freemo]: Verify the ASV benchmark from #537 runs correctly. - [ ] Quality [freemo]: 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 improve 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%. - [ ] Quality [freemo]: 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. Parent: #401 Blocked by: #537
freemo added this to the v3.2.0 milestone 2026-03-04 00:42:19 +00:00
freemo self-assigned this 2026-03-04 01:41:11 +00:00
Owner

Implementation Summary

Root cause: bootstrap_builtin_types() in ResourceRegistryService was never called during project initialization, so built-in resource types (including fs-directory) were not seeded into the database.

Fix: Added a call to bootstrap_builtin_types() in init_command() in src/cleveragents/cli/commands/project.py (after project_service.initialize_project() returns). The call is idempotent and placed after initialize_project() because the database tables are created there via unit_of_work.init_database().

Additional fixes in the same commit:

  • Fixed the TDD robot test (resource_type_bootstrap_git.robot) to properly initialize a project before running resource add, since the CLI command requires an initialized project with a database.
  • Fixed a pre-existing parallel test failure in plan_commands_new_coverage.feature:78 where unittest.mock.patch couldn't reliably intercept PlanApplyService under behave-parallel's fork()-based workers. The fix patches PlanApplyService at both the canonical source module and the plan module (with create=True).

Verification: All nox stages pass — lint, typecheck, unit_tests (8940 scenarios, 0 failures), integration_tests (1286 tests, 0 failures), coverage_report (97%).

## Implementation Summary **Root cause:** `bootstrap_builtin_types()` in `ResourceRegistryService` was never called during project initialization, so built-in resource types (including `fs-directory`) were not seeded into the database. **Fix:** Added a call to `bootstrap_builtin_types()` in `init_command()` in `src/cleveragents/cli/commands/project.py` (after `project_service.initialize_project()` returns). The call is idempotent and placed after `initialize_project()` because the database tables are created there via `unit_of_work.init_database()`. **Additional fixes in the same commit:** - Fixed the TDD robot test (`resource_type_bootstrap_git.robot`) to properly initialize a project before running `resource add`, since the CLI command requires an initialized project with a database. - Fixed a pre-existing parallel test failure in `plan_commands_new_coverage.feature:78` where `unittest.mock.patch` couldn't reliably intercept `PlanApplyService` under `behave-parallel`'s `fork()`-based workers. The fix patches `PlanApplyService` at both the canonical source module and the plan module (with `create=True`). **Verification:** All nox stages pass — lint, typecheck, unit_tests (8940 scenarios, 0 failures), integration_tests (1286 tests, 0 failures), coverage_report (97%).
Sign in to join this conversation.
No milestone
No project
No assignees
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.

Reference
cleveragents/cleveragents-core#523
No description provided.