🧹 Refactor verify_pull_request to extract helper functions - #71
Conversation
…utput preparation logic into module-level functions. This change breaks down the highly complex and deeply nested `verify_pull_request` function in `src/titmas_action_gate/pr_gate.py`. Nested functions (`abort_reserved`, `reserve`, `reserve_private`) and inline logic for preparing outputs have been extracted to private module-level functions (`_abort_reserved`, `_reserve_outputs`, `_reserve_private_outputs`, `_prepare_outputs`, `_output_integrity_state`), improving maintainability without changing any functionality. Co-authored-by: joy7758 <138868899+joy7758@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bfc30ff04c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| ) -> dict[str, Any]: | ||
| """Run one bounded PR verification and create its receipt and summary once.""" | ||
|
|
||
| requested_output, output, receipt_output, summary_output, output_preflight_safe, output_preflight_reason = _prepare_outputs(output_directory) |
There was a problem hiding this comment.
Update the recommendation gate before refactoring
This refactor changes the core pull-request gate without updating governance/agent-recommendation-gate.json; at this commit, that record still describes the unrelated CLOSE_FINAL_THREE_MERGE_GATE_P1_FINDINGS task, branch, and base commit. Refresh it for this development scope so the required recommendation, non-recommendation reasons, correction evidence, remaining gaps, and stop conditions are recorded rather than leaving stale governance metadata.
AGENTS.md reference: AGENTS.md:L23-L27
Useful? React with 👍 / 👎.
This resolves the CI failure by fixing lint and format errors found by `ruff` (unused imports, improper import sorting, and unnecessary read modes for `open`). These changes were applied to `tests/test_security_argument_injection.py`, `tests/test_workflow.py`, and `src/titmas_action_gate/service.py`. Co-authored-by: joy7758 <138868899+joy7758@users.noreply.github.com>
🎯 What: Extracted nested helper functions and output preparation logic from
verify_pull_requestinsrc/titmas_action_gate/pr_gate.pyinto distinct module-level functions (_prepare_outputs,_reserve_outputs, etc.).💡 Why:
verify_pull_requestwas extremely long and complex, mixing high-level logic with low-level details (like temp directory setup). By extracting these to the module level, the main function is much easier to read, test, and maintain.✅ Verification: Verified by running
python3 -m unittest discover -s tests -v, governance scripts, and reviewing the code. Code review confirmed no functional regressions and gave it a "Correct" rating.✨ Result: Improved readability and reduced cognitive load in a core gate validation function.
PR created automatically by Jules for task 2416905046819582448 started by @joy7758