agents resource add git-checkout should not cause an error. #524

Closed
opened 2026-03-03 01:49:59 +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 git-checkout local/quadratic --path /home/devuser/git-dir --branch master fails with "Resource type not found: git-checkout". This is the same root cause as #523: 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.

This bug shares the same root cause and fix as #523. The fix commit for #523 will resolve this issue as well. The test for this specific resource type is tracked in #553.

Expected Behavior

After agents init, git-checkout is available as a built-in resource type and agents resource add git-checkout succeeds.

Acceptance Criteria

  • agents resource add git-checkout local/test --path /tmp/repo --branch main succeeds after agents init.
  • All failing tests from #553 now pass.
  • Fix is the same commit as #523 (shared branch feature/m3-fix-resource-bootstrap).

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]: Same fix as #523 — ensure bootstrap_builtin_types() is called during initialization so git-checkout type is available.
  • Tests (Behave) [freemo]: Verify that the git-checkout specific Behave scenarios from #553 pass.
  • Tests (Robot) [freemo]: Verify the Robot smoke test from #553 passes for git-checkout.
  • 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 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: #553

## Metadata - **Commit Message**: `fix(resource): call bootstrap_builtin_types during initialization` - **Branch**: `feature/m3-fix-resource-bootstrap` ## Background and Context `agents resource add git-checkout local/quadratic --path /home/devuser/git-dir --branch master` fails with "Resource type not found: git-checkout". This is the same root cause as #523: `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. **This bug shares the same root cause and fix as #523.** The fix commit for #523 will resolve this issue as well. The test for this specific resource type is tracked in #553. ## Expected Behavior After `agents init`, `git-checkout` is available as a built-in resource type and `agents resource add git-checkout` succeeds. ## Acceptance Criteria - [ ] `agents resource add git-checkout local/test --path /tmp/repo --branch main` succeeds after `agents init`. - [ ] All failing tests from #553 now pass. - [ ] Fix is the same commit as #523 (shared branch `feature/m3-fix-resource-bootstrap`). ## 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]: Same fix as #523 — ensure `bootstrap_builtin_types()` is called during initialization so `git-checkout` type is available. - [ ] Tests (Behave) [freemo]: Verify that the `git-checkout` specific Behave scenarios from #553 pass. - [ ] Tests (Robot) [freemo]: Verify the Robot smoke test from #553 passes for git-checkout. - [ ] 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 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: #553
freemo added this to the v3.2.0 milestone 2026-03-04 00:42:28 +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 git-checkout) 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 `git-checkout`) 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#524
No description provided.