fix(policies): detect and wrap legacy (content, phase) callables in resolve_function_policy - #49
Conversation
…esolve_function_policy
|
note for reviewers: if this fix looks correct, i can add the above modification to this PR if approved. |
|
LGTM thanks for the PR! |
@PattaraS thanks for the review! i would like to mention this again. what would you suggest? |
|
@aarushisingh04 That makes sense to me! Thanks for the note, we can mark the gap as fixed :) |
|
@PattaraS great! i have added the updated status in the docs for gap 7, would appreciate a final review! |
PattaraS
left a comment
There was a problem hiding this comment.
LGTM. Thanks again for the contribution!
|
/merge |
|
🤖 |
Summary
closes Gap 7 from
tests/e2e/omnigent/TODO_omnigent_coverage.md: legacy omnigent(content, phase)policy callables silently no-oping underresolve_function_policy.resolve_function_policynow detects legacy omnigent-style(content, phase)callables by inspecting the first two positional parameter names, and wraps them via theexisting _omnigent_legacy_shim._wrap_legacybefore storing them inFunctionPolicy. without this, any callable with that signature would silentlyALLOWevery event, thephase == "tool_call"check always fails whenphasereceives an event dict instead of a string.function.py → _omnigent_legacy_shim → policies.types → policies.__init__ → function.py.(event)callables are unaffected; the adapter path(handler:→_translate_function_policy_yaml→ shim factory) is also unaffected and does not double-wrap.Type of change
Test coverage
Coverage rationale
three unit tests appended to
tests/runtime/policies/test_function_policy.pyunder the Gap 7 section:test_resolve_function_policy_wraps_legacy_callable: asserts thatresolve_function_policywith a(content, phase)callable produces aFunctionPolicy(detection and wrapping succeed at build time).test_resolve_function_policy_legacy_callable_evaluates_correctly: asserts the wrapped callable returns the correctDENYaction and reason at evaluation time, verifying the full shim path including_coerce_legacy_return.test_resolve_function_policy_modern_callable_not_wrapped: asserts a modern(event)callable passes through unchanged, confirmed by checkingpolicy._callable.__name__ == "modern_allow"(shim inners are named_sync_shim/_async_shim).no E2E coverage added: the omnigent example callables (
block_long_sleep, etc.) were already rewritten to the modern single-arg format before this PR, so no existing e2e fixture exercises a legacy callable viaresolve_function_policy. the unit tests above are the only coverage of this path. E2E verification would require introducing a legacy-signature callable into an example YAML, which is out of scope for this fix.