Fix v1 lifecycle handler discovery#1347
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019e181b-75e8-70ab-b5a4-beceba9121f2
6890a9f to
2c375c5
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 2c375c5. Configure here.
| handlers.append(cast(Callable[..., object], handler)) | ||
| for _, method in inspect.getmembers(toolset, predicate=callable): | ||
| if not getattr(method, attr, False): | ||
| if getattr(method, attr, False) is not True: |
There was a problem hiding this comment.
Missed handler discovery fix at third occurrence
Medium Severity
The _toolset_binding_targets method at line 966 still uses the old truthiness check (getattr(method, attr, False)) to discover lifecycle handler methods, while the same pattern was intentionally tightened to is True in _rollout_handlers and collect_handlers. This means _toolset_binding_targets can still falsely pick up unrelated callable attributes as lifecycle handler binding targets — the exact bug this PR intends to fix.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 2c375c5. Configure here.


Summary
TrueValidation
uv run ruff check verifiers/v1/utils/lifecycle_utils.pyuv run ruff format --check verifiers/v1/utils/lifecycle_utils.pyNote
Medium Risk
Changes which callables are discovered as lifecycle handlers by requiring marker attributes to be exactly
True, which could alter runtime behavior for existing toolsets that relied on truthy non-boolean markers.Overview
Fixes v1 lifecycle handler discovery so only callables explicitly marked with lifecycle attributes (e.g.
stop,setup,update,cleanup) set toTrueare collected.This tightens handler filtering in both
Runtime._rollout_handlersandcollect_handlers, reducing accidental pickup of unrelated callable members and making stage-based lifecycle execution more predictable.Reviewed by Cursor Bugbot for commit 2c375c5. Bugbot is set up for automated code reviews on this repo. Configure here.