Commit b965e66
authored
refactor(models): reject legacy action values at API boundaries (#163)
## Summary
- Split action validation into strict (`validate_action`) for API input
boundaries and lenient (`normalize_action`) for internal read paths
- `ControlAction.decision` now rejects `allow`/`warn`/`log` with a clear
error — only `deny`, `steer`, `observe` are accepted when creating or
updating controls
- `EventQueryRequest.actions` now rejects legacy values in query filters
- `ControlMatch` and `ControlExecutionEvent` still normalize legacy
values from historical DB rows via `normalize_action`
- `expand_action_filter` unchanged — still expands `observe` to include
legacy values for SQL queries against old event data
Follows #161 which introduced the `observe` action and normalization
layer.
## Test plan
- [x] `models/tests/test_actions.py` — 43 tests covering strict
validation, lenient normalization, Pydantic model boundaries, and query
expansion
- [x] `server/tests/test_observability_models.py` — updated to verify
legacy rejection in query filters
- [x] `engine/tests/test_core.py` — 49 tests pass (unchanged)
- [x] `sdks/python/tests/test_control_decorators.py` — 35 tests pass
(unchanged)
- [x] `make lint` and `make typecheck` pass
🤖 Generated with [Claude Code](https://claude.com/claude-code)1 parent 275d305 commit b965e66
8 files changed
Lines changed: 317 additions & 79 deletions
File tree
- models
- src/agent_control_models
- tests
- sdks/python/tests
- server/tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
16 | 18 | | |
17 | 19 | | |
| |||
144 | 146 | | |
145 | 147 | | |
146 | 148 | | |
| 149 | + | |
| 150 | + | |
147 | 151 | | |
148 | 152 | | |
149 | 153 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
10 | 11 | | |
11 | 12 | | |
12 | 13 | | |
| |||
15 | 16 | | |
16 | 17 | | |
17 | 18 | | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
18 | 45 | | |
19 | | - | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
20 | 51 | | |
21 | 52 | | |
22 | 53 | | |
23 | 54 | | |
24 | 55 | | |
25 | | - | |
26 | | - | |
| 56 | + | |
27 | 57 | | |
28 | 58 | | |
29 | 59 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
520 | 520 | | |
521 | 521 | | |
522 | 522 | | |
523 | | - | |
524 | | - | |
| 523 | + | |
| 524 | + | |
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
18 | 22 | | |
19 | 23 | | |
20 | 24 | | |
| |||
343 | 347 | | |
344 | 348 | | |
345 | 349 | | |
346 | | - | |
| 350 | + | |
347 | 351 | | |
348 | 352 | | |
349 | 353 | | |
350 | 354 | | |
351 | | - | |
| 355 | + | |
352 | 356 | | |
353 | 357 | | |
354 | 358 | | |
| |||
0 commit comments