fix(resources): fix ResourceTypeSpec inheritance cycle detection for multi-level cycles #10633

Merged
HAL9000 merged 5 commits from fix/v360/resource-type-cycle-detection into master 2026-06-06 03:51:29 +00:00

5 Commits

Author SHA1 Message Date
cleveragents-auto 90e23b0aed chore: worker ruff auto-fix (pre-push lint gate)
CI / lint (pull_request) Successful in 1m14s
CI / push-validation (pull_request) Successful in 56s
CI / quality (pull_request) Successful in 1m18s
CI / typecheck (pull_request) Successful in 1m29s
CI / security (pull_request) Successful in 1m29s
CI / helm (pull_request) Successful in 1m10s
CI / build (pull_request) Successful in 1m15s
CI / unit_tests (pull_request) Successful in 6m39s
CI / integration_tests (pull_request) Successful in 10m8s
CI / docker (pull_request) Successful in 2m50s
CI / coverage (pull_request) Successful in 21m27s
CI / status-check (pull_request) Successful in 7s
2026-06-05 23:20:31 -04:00
HAL9000 715a5d9d78 fix(resources): resolve AmbiguousStep, wire registry context into _validate_model, add depth limit
- Fix AmbiguousStep: rename step decorator from
  'the creation should fail with "{fragment1}" or "{fragment2}"' to
  'the creation should fail with either "{fragment1}" or "{fragment2}"'
  so behave parse does not treat it as ambiguous with the single-arg form;
  this was causing all 8 features to error on step load, failing CI.

- Wire registry into _validate_model(): add ValidationInfo parameter and
  extract type_registry from Pydantic validation context so multi-level
  cycle detection (A->B->A, A->B->C->A) runs through the production code
  path, not just as a pre-creation standalone call.

- Update BDD steps to use ResourceTypeSpec.model_validate(..., context=
  {"type_registry": registry}) instead of calling detect_inheritance_cycles
  directly before construction, so tests validate the actual fix path.

- Add MAX_INHERITANCE_DEPTH = 100 constant and depth counter in
  detect_inheritance_cycles() while loop to guard against DoS via
  pathologically deep chains.

- Consolidate five separate import blocks from _resource_type_validation
  into a single grouped import in resource_type.py.

- Add depth-limit scenario and step covering the new MAX_INHERITANCE_DEPTH
  guard to ensure new lines are covered by diff-coverage.
2026-06-05 23:20:31 -04:00
HAL9000 078ca52c22 style: apply ruff format to resource_type_inheritance_cycle_detection_steps.py
Collapse two-line function signature to single line to satisfy ruff format check.
2026-06-05 23:20:31 -04:00
HAL9000 f8b65bab12 fix(resources): fix ResourceTypeSpec inheritance cycle detection for multi-level cycles
- Fix unsorted imports in resource_type_inheritance_cycle_detection_steps.py (ruff I001)
- Add missing step definition for 'the creation should fail with "X" or "Y"' pattern
- Wire detect_inheritance_cycles() with registry in step definitions so multi-level
  cycles (A→B→A, A→B→C→A) are properly detected during BDD test execution
2026-06-05 23:20:31 -04:00
HAL9000 9a4d709cd1 fix(validation): detect multi-step inheritance cycles in ResourceTypeSpec
- Add detect_inheritance_cycles() function to _resource_type_validation.py
- Function detects both direct self-inheritance (A→A) and multi-level cycles (A→B→A, A→B→C→A)
- Add BDD tests for cycle detection scenarios
- Tests cover direct self-inheritance, two-level cycles, three-level cycles, and valid chains
2026-06-05 23:20:31 -04:00