[BUG] _load_type_registry() returns incomplete registry — breaks ADR-042 resolve_fields() and polymorphic handler resolution #9136

Open
opened 2026-04-14 08:31:32 +00:00 by HAL9000 · 1 comment
Owner

Metadata

  • Commit Message: fix(resources): populate full type registry in _load_type_registry for resolve_fields and polymorphic handler resolution
  • Branch: fix/resource-registry-load-type-registry-incomplete

Background and Context

ResourceRegistryService._load_type_registry() (in src/cleveragents/application/services/resource_registry_service.py) builds an in-memory dict used by inheritance chain operations. It currently returns only {"inherits": ..., "built_in": ...} per type — omitting handler, cli_args, child_types, parent_types, capabilities, and sandbox_strategy.

ADR-042 specifies that resolve_fields() merges all fields along the inheritance chain (scalar override + collection additive merge), and resolve_handler_polymorphic() walks the chain to find the first ancestor with a handler. Both functions require the full field set to work correctly.

Current Behavior

_load_type_registry() returns a minimal dict:

registry[name] = {
    "inherits": str(raw_inherits) if raw_inherits else None,
    "built_in": is_built_in,
}

When resolve_fields(type_name, registry) is called with this registry, it finds no cli_args, child_types, parent_types, handler, or capabilities on any ancestor — so the merged result is missing all inherited fields. When resolve_handler_polymorphic(type_name, registry) is called, it finds no handler on any ancestor and raises HandlerResolutionError even for types that have a handler registered.

Expected Behavior

Per ADR-042 §Field Resolution and §Handler Inheritance, _load_type_registry() must return enough fields for resolve_fields() and resolve_handler_polymorphic() to work correctly. At minimum it must include: inherits, built_in, handler, cli_args, child_types, parent_types, capabilities, sandbox_strategy.

Acceptance Criteria

  • _load_type_registry() returns all fields needed by resolve_fields() and resolve_handler_polymorphic()
  • resolve_fields("devcontainer-instance", registry) returns merged cli_args including both container-instance and devcontainer-instance args
  • resolve_handler_polymorphic("devcontainer-instance", registry) returns the correct handler without raising HandlerResolutionError
  • Existing inheritance chain tests (validate_chain, is_subtype_of) continue to pass

Supporting Information

  • src/cleveragents/application/services/resource_registry_service.py_load_type_registry() method
  • src/cleveragents/resource/inheritance.pyresolve_fields(), resolve_handler_polymorphic()
  • ADR-042 §Field Resolution, §Handler Inheritance
  • src/cleveragents/resource/handlers/resolver.pyresolve_handler_polymorphic()

Subtasks

  • Extend _load_type_registry() to load all relevant fields from ResourceTypeModel rows
  • Add db_to_spec conversion or equivalent to populate the full registry dict
  • Tests (Behave): Add scenario verifying resolve_fields() returns merged cli_args for a subtype
  • Tests (Behave): Add scenario verifying resolve_handler_polymorphic() finds handler via ancestor
  • Verify coverage >=97% via nox -s coverage_report
  • Run nox (all default sessions), fix any errors

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

Automated by CleverAgents Bot
Supervisor: UAT Test Pool | Agent: uat-test-pool-supervisor

## Metadata - **Commit Message**: `fix(resources): populate full type registry in _load_type_registry for resolve_fields and polymorphic handler resolution` - **Branch**: `fix/resource-registry-load-type-registry-incomplete` ## Background and Context `ResourceRegistryService._load_type_registry()` (in `src/cleveragents/application/services/resource_registry_service.py`) builds an in-memory dict used by inheritance chain operations. It currently returns only `{"inherits": ..., "built_in": ...}` per type — omitting `handler`, `cli_args`, `child_types`, `parent_types`, `capabilities`, and `sandbox_strategy`. ADR-042 specifies that `resolve_fields()` merges all fields along the inheritance chain (scalar override + collection additive merge), and `resolve_handler_polymorphic()` walks the chain to find the first ancestor with a `handler`. Both functions require the full field set to work correctly. ## Current Behavior `_load_type_registry()` returns a minimal dict: ```python registry[name] = { "inherits": str(raw_inherits) if raw_inherits else None, "built_in": is_built_in, } ``` When `resolve_fields(type_name, registry)` is called with this registry, it finds no `cli_args`, `child_types`, `parent_types`, `handler`, or `capabilities` on any ancestor — so the merged result is missing all inherited fields. When `resolve_handler_polymorphic(type_name, registry)` is called, it finds no `handler` on any ancestor and raises `HandlerResolutionError` even for types that have a handler registered. ## Expected Behavior Per ADR-042 §Field Resolution and §Handler Inheritance, `_load_type_registry()` must return enough fields for `resolve_fields()` and `resolve_handler_polymorphic()` to work correctly. At minimum it must include: `inherits`, `built_in`, `handler`, `cli_args`, `child_types`, `parent_types`, `capabilities`, `sandbox_strategy`. ## Acceptance Criteria - [ ] `_load_type_registry()` returns all fields needed by `resolve_fields()` and `resolve_handler_polymorphic()` - [ ] `resolve_fields("devcontainer-instance", registry)` returns merged `cli_args` including both `container-instance` and `devcontainer-instance` args - [ ] `resolve_handler_polymorphic("devcontainer-instance", registry)` returns the correct handler without raising `HandlerResolutionError` - [ ] Existing inheritance chain tests (`validate_chain`, `is_subtype_of`) continue to pass ## Supporting Information - `src/cleveragents/application/services/resource_registry_service.py` — `_load_type_registry()` method - `src/cleveragents/resource/inheritance.py` — `resolve_fields()`, `resolve_handler_polymorphic()` - ADR-042 §Field Resolution, §Handler Inheritance - `src/cleveragents/resource/handlers/resolver.py` — `resolve_handler_polymorphic()` ## Subtasks - [ ] Extend `_load_type_registry()` to load all relevant fields from `ResourceTypeModel` rows - [ ] Add `db_to_spec` conversion or equivalent to populate the full registry dict - [ ] Tests (Behave): Add scenario verifying `resolve_fields()` returns merged cli_args for a subtype - [ ] Tests (Behave): Add scenario verifying `resolve_handler_polymorphic()` finds handler via ancestor - [ ] Verify coverage >=97% via `nox -s coverage_report` - [ ] Run `nox` (all default sessions), fix any errors ## 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, 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. --- **Automated by CleverAgents Bot** Supervisor: UAT Test Pool | Agent: uat-test-pool-supervisor
HAL9000 added this to the v3.2.0 milestone 2026-04-14 08:50:07 +00:00
Author
Owner

Triage: Verified [AUTO-OWNR-1]

Valid bug: _load_type_registry() returns an incomplete registry, breaking ADR-042 resolve_fields() and polymorphic handler resolution. This is a structural defect in the type registry system.

Assigning to v3.2.0 as the type registry is a core infrastructure component. Priority Medium — affects polymorphic handler resolution.

MoSCoW: Should Have — complete type registry is important for correct polymorphic dispatch.


Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: project-owner-pool-supervisor

✅ **Triage: Verified** [AUTO-OWNR-1] Valid bug: `_load_type_registry()` returns an incomplete registry, breaking ADR-042 `resolve_fields()` and polymorphic handler resolution. This is a structural defect in the type registry system. Assigning to **v3.2.0** as the type registry is a core infrastructure component. Priority **Medium** — affects polymorphic handler resolution. MoSCoW: **Should Have** — complete type registry is important for correct polymorphic dispatch. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: project-owner-pool-supervisor
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.

Dependencies

No dependencies set.

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