Commit Graph

35 Commits

Author SHA1 Message Date
kevin zhao
43db77a97b feat: implementing parse_many 2025-11-13 22:08:06 -05:00
kevin zhao
2e14f258c3 now keeping PolicyBuilder in a RefCell, allowing add_rule to take &mut self w/o Mutex 2025-11-13 22:07:46 -05:00
kevin zhao
ae17058704 directly passing starlark error 2025-11-13 22:07:45 -05:00
kevin zhao
820e26f9d2 better naming in Policy.parse() 2025-11-13 22:07:45 -05:00
kevin zhao
175e3530bc move validation logic to rule.rs 2025-11-13 22:07:45 -05:00
kevin zhao
c7993e0471 conslidate validate_match_examples and validate_not_match_examples 2025-11-13 22:07:45 -05:00
kevin zhao
dc76907771 refactor: rule traits 2025-11-13 22:07:45 -05:00
kevin zhao
f7fa9c5c0f using expect to provide more context if unwraps fail 2025-11-13 22:07:45 -05:00
kevin zhao
556510f378 avoid matching on as_slice() when you can use is_empty() 2025-11-13 22:07:45 -05:00
kevin zhao
ffdebc2937 again, more descriptive error messages 2025-11-13 22:07:44 -05:00
kevin zhao
9b3041ffe5 print out actual type in error message 2025-11-13 22:07:44 -05:00
kevin zhao
80c67243df cleanup 2025-11-13 22:07:44 -05:00
kevin zhao
ceea9075ea docstrings and other cleanup 2025-11-13 22:07:44 -05:00
kevin zhao
842d6adb59 refactor to test positive matches 2025-11-13 22:07:44 -05:00
kevin zhao
e51178cb27 consolidate new() and parse() in PolicyParser 2025-11-13 22:07:44 -05:00
kevin zhao
7b5916cb4b Share prefix pattern data in execpolicy2 instead of cloning 2025-11-13 22:07:43 -05:00
kevin zhao
8c909a0084 making things more functional 2025-11-13 22:07:43 -05:00
kevin zhao
2f8d3f6b42 code cleanup 2025-11-13 22:07:42 -05:00
kevin zhao
17f86a6c86 clippy 2025-11-13 22:07:42 -05:00
kevin zhao
d3aafb93f3 feat: tokenizing whole strings in match and not_match 2025-11-13 22:07:42 -05:00
kevin zhao
755331425e refactor: implementing rule traits, rulematch enum 2025-11-13 22:07:41 -05:00
kevin zhao
8834e4bbdc helper function to get PolicyBuilder + only getting one builder in prefix_rule 2025-11-13 22:07:40 -05:00
kevin zhao
ff09321eb1 updated error messaging to indicate type 2025-11-13 22:07:40 -05:00
kevin zhao
a67521926a fmt 2025-11-13 22:07:40 -05:00
kevin zhao
17bb82de77 using .iter() instead of mut 2025-11-13 22:07:40 -05:00
kevin zhao
b03c3c3d1f more early return lines 2025-11-13 22:07:40 -05:00
kevin zhao
90411d6e90 [parser.rs] match token vector on length 2025-11-13 22:07:39 -05:00
zhao-oai
1b09f32cd5 Update codex-rs/execpolicy2/src/parser.rs
Co-authored-by: Michael Bolin <mbolin@openai.com>
2025-11-13 22:07:39 -05:00
kevin zhao
b405a8c812 refactor parse_pattern to use iterator chain 2025-11-13 22:07:39 -05:00
kevin zhao
bc375db0ab using parking_lot mutex + AtomicU64 for auto id 2025-11-13 22:07:38 -05:00
kevin zhao
64e786caad simplify 2025-11-13 22:07:37 -05:00
kevin zhao
9aea52efb1 simplify logic 2025-11-13 22:07:37 -05:00
kevin zhao
7e79c4dc5b refactor rules so no more cartesian product 2025-11-13 22:07:37 -05:00
kevin zhao
eea9bff1fb remove tokenize_command use cases 2025-11-13 22:07:37 -05:00
kevin zhao
773177ec8b first pass at prefix rules 2025-11-13 22:07:37 -05:00