argus-code-review 0.4.2__tar.gz → 0.4.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/CHANGELOG.md +9 -1
  2. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/PKG-INFO +1 -1
  3. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/graph.py +29 -3
  4. argus_code_review-0.4.3/tests/test_prior_sha_unreachable.py +54 -0
  5. argus_code_review-0.4.3/tests/test_round2_pr_scope.py +57 -0
  6. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/.gitignore +0 -0
  7. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/LICENSE +0 -0
  8. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/README.md +0 -0
  9. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/__init__.py +0 -0
  10. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/bench.py +0 -0
  11. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/bench_default.toml +0 -0
  12. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/cli.py +0 -0
  13. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/config.py +0 -0
  14. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/coverage.py +0 -0
  15. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/dotenv_utils.py +0 -0
  16. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/gemini_cache.py +0 -0
  17. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/gemini_runner.py +0 -0
  18. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/github_client.py +0 -0
  19. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/helpers.py +0 -0
  20. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/llm/models.py +0 -0
  21. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/llm/output_models.py +0 -0
  22. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/llm/pricing.py +0 -0
  23. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/llm/usage.py +0 -0
  24. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/models.py +0 -0
  25. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/openai_client.py +0 -0
  26. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/openai_runner.py +0 -0
  27. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/pipeline_models.py +0 -0
  28. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/__init__.py +0 -0
  29. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/actions_scanner.py +0 -0
  30. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/engine.py +0 -0
  31. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/eslint_bundle/.gitignore +0 -0
  32. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/eslint_bundle/README.md +0 -0
  33. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/eslint_bundle/eslint.config.js +0 -0
  34. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/eslint_bundle/package-lock.json +0 -0
  35. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/eslint_bundle/package.json +0 -0
  36. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/js_scanner.py +0 -0
  37. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/migration_scanner.py +0 -0
  38. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/rules/README.md +0 -0
  39. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/sarif.py +0 -0
  40. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/scanner_utils.py +0 -0
  41. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/secrets_scanner.py +0 -0
  42. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/shadow.py +0 -0
  43. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/terraform_scanner.py +0 -0
  44. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/precheck/workflow_lint_scanner.py +0 -0
  45. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/__init__.py +0 -0
  46. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-blocking-validator.md +0 -0
  47. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-coverage-check.md +0 -0
  48. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-cross-cutting.md +0 -0
  49. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-feedback-verifier.md +0 -0
  50. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-lite.md +0 -0
  51. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-planner.md +0 -0
  52. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-preflight-router.md +0 -0
  53. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-prior-art.md +0 -0
  54. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-scope.md +0 -0
  55. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-specialist-deployment.md +0 -0
  56. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-specialist-frontend.md +0 -0
  57. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-specialist-infra.md +0 -0
  58. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-specialist-llm-patterns.md +0 -0
  59. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-specialist-observability.md +0 -0
  60. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-specialist-orchestration.md +0 -0
  61. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-specialist-security.md +0 -0
  62. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-specialist-slackbot.md +0 -0
  63. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-specialist-sql.md +0 -0
  64. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-subagent.md +0 -0
  65. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-tests-and-docs.md +0 -0
  66. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts/pr-review-writer.md +0 -0
  67. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/prompts_runtime.py +0 -0
  68. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/repo_provision.py +0 -0
  69. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/review_tools.py +0 -0
  70. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/runners.py +0 -0
  71. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/scope.py +0 -0
  72. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/storage/__init__.py +0 -0
  73. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/storage/http.py +0 -0
  74. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/storage/models.py +0 -0
  75. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/storage/precheck.py +0 -0
  76. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/storage/resolver.py +0 -0
  77. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/storage/session.py +0 -0
  78. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/storage/sql.py +0 -0
  79. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/argus/storage/sqlite.py +0 -0
  80. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/pyproject.toml +0 -0
  81. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/schema/008_add_code_reviews.sql +0 -0
  82. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/schema/009_add_reviewer_version.sql +0 -0
  83. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/schema/010_add_review_patterns.sql +0 -0
  84. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/schema/011_add_review_progress_columns.sql +0 -0
  85. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/schema/015_create_agent_runs.sql +0 -0
  86. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/schema/016_add_agent_runs_failure_reason.sql +0 -0
  87. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/schema/017_add_precheck_rules.sql +0 -0
  88. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/schema/018_widen_agent_runs_failure_reason.sql +0 -0
  89. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/__init__.py +0 -0
  90. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/conftest.py +0 -0
  91. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/golden/review_response.schema.json +0 -0
  92. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/storage/__init__.py +0 -0
  93. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/storage/test_backend_contract.py +0 -0
  94. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/storage/test_http.py +0 -0
  95. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/storage/test_models.py +0 -0
  96. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/storage/test_resolver.py +0 -0
  97. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/storage/test_session.py +0 -0
  98. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/storage/test_sql.py +0 -0
  99. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/storage/test_sqlite_backend.py +0 -0
  100. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_actions_scanner.py +0 -0
  101. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_argus_review_local.py +0 -0
  102. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_bench.py +0 -0
  103. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_bench_config_guard.py +0 -0
  104. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_catchup_gate.py +0 -0
  105. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_cli_args.py +0 -0
  106. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_cli_output_contract.py +0 -0
  107. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_cli_post_review.py +0 -0
  108. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_cli_preflight.py +0 -0
  109. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_cli_prompts.py +0 -0
  110. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_config.py +0 -0
  111. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_conftest.py +0 -0
  112. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_dotenv_utils.py +0 -0
  113. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_failure_diagnostics.py +0 -0
  114. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_gemini_cache.py +0 -0
  115. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_gemini_http_retry.py +0 -0
  116. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_gemini_runner.py +0 -0
  117. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_github_client_checks_signal.py +0 -0
  118. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_github_client_write.py +0 -0
  119. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_graph_fetch_diff.py +0 -0
  120. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_graph_get_llm_temperature.py +0 -0
  121. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_graph_http_guards.py +0 -0
  122. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_graph_precheck.py +0 -0
  123. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_graph_preflight_image_bump.py +0 -0
  124. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_graph_progress.py +0 -0
  125. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_graph_storage_resolution.py +0 -0
  126. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_graph_timeout_surfacing.py +0 -0
  127. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_js_scanner.py +0 -0
  128. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_llm_models.py +0 -0
  129. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_llm_models_override.py +0 -0
  130. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_llm_pricing.py +0 -0
  131. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_migration_scanner.py +0 -0
  132. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_models.py +0 -0
  133. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_multi_round.py +0 -0
  134. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_openai_client.py +0 -0
  135. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_openai_runner.py +0 -0
  136. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_output_models.py +0 -0
  137. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_packaging.py +0 -0
  138. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_plan_review.py +0 -0
  139. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_precheck_engine.py +0 -0
  140. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_precheck_engine_integration.py +0 -0
  141. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_precheck_sarif.py +0 -0
  142. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_precheck_shadow.py +0 -0
  143. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_precheck_shadow_integration.py +0 -0
  144. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_prompts.py +0 -0
  145. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_repo_provision.py +0 -0
  146. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_review_patterns_integration.py +0 -0
  147. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_review_tools.py +0 -0
  148. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_runners_context7.py +0 -0
  149. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_runners_context_usage.py +0 -0
  150. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_runners_helpers.py +0 -0
  151. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_runners_new.py +0 -0
  152. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_runners_turn_budget.py +0 -0
  153. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_scanner_utils.py +0 -0
  154. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_scope.py +0 -0
  155. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_scope_gate.py +0 -0
  156. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_sdk_bundled_cli_version.py +0 -0
  157. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_secrets_scanner.py +0 -0
  158. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_specialist_validation.py +0 -0
  159. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_stage_costs.py +0 -0
  160. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_storage_precheck.py +0 -0
  161. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_structured_output_methods.py +0 -0
  162. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_terraform_scanner.py +0 -0
  163. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_terraform_scanner_integration.py +0 -0
  164. {argus_code_review-0.4.2 → argus_code_review-0.4.3}/tests/test_workflow_lint_scanner.py +0 -0
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.4.3] - 2026-11-18
11
+
12
+ ### Fixed
13
+
14
+ - Round 2+ reviews no longer halt with `dispatch_budget_exceeded` after a catch-up merge from the base branch. The round's diff (`prior_sha...head`) held every change the merge brought in, so the planner fanned out over code the PR did not write (for example 65 files for an 8-file PR). The diff now keeps only the files the PR itself changes, and stays whole when the PR file list cannot be confirmed. A file that both the PR and the base branch changed still shows the base branch's lines.
15
+ - A prior review whose commit no longer exists in the repo no longer fails the round with a GitHub 404 (reported by the service as `worker_error`). Storage keys prior rounds by repo and PR number, so a recreated repo or a rewritten history can return such a round. Argus now logs a warning and reviews the whole PR as round 1.
16
+
10
17
  ## [0.4.2] - 2026-10-29
11
18
 
12
19
  ### Changed
@@ -475,7 +482,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
475
482
  packaged set.
476
483
  - `argus --version`, `argus prompts list`, and `argus prompts export`.
477
484
 
478
- [Unreleased]: https://github.com/redesignhealth/argus-review/compare/v0.4.1...HEAD
485
+ [Unreleased]: https://github.com/redesignhealth/argus-review/compare/v0.4.3...HEAD
486
+ [0.4.3]: https://github.com/redesignhealth/argus-review/compare/v0.4.2...v0.4.3
479
487
  [0.4.2]: https://github.com/redesignhealth/argus-review/compare/v0.4.1...v0.4.2
480
488
  [0.4.1]: https://github.com/redesignhealth/argus-review/compare/v0.4.0...v0.4.1
481
489
  [0.4.0]: https://github.com/redesignhealth/argus-review/compare/v0.3.4...v0.4.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: argus-code-review
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Self-orchestrated PR review agent using LangGraph + Claude Agent SDK
5
5
  Project-URL: Repository, https://github.com/redesignhealth/argus-review
6
6
  Project-URL: Issues, https://github.com/redesignhealth/argus-review/issues
@@ -43,6 +43,7 @@ from argus.helpers import (
43
43
  apply_bench_config_change_gate,
44
44
  apply_precheck_gate_and_surface_degraded_coverage,
45
45
  compute_persisted_finding_counts,
46
+ filter_diff_for_files,
46
47
  )
47
48
  from argus.llm.models import ALIAS_MAP, CLAUDE_DEFAULT, CLAUDE_FRONTIER, CLAUDE_MINI
48
49
  from argus.llm.usage import (
@@ -2505,6 +2506,8 @@ async def _node_fetch_diff(state: ReviewState, config: RunnableConfig) -> dict[s
2505
2506
  Also fetches the prior review from storage. If a prior review exists,
2506
2507
  the diff is scoped to reviewed_sha..HEAD (round 2+).
2507
2508
  """
2509
+ from argus.github_client import GitHubAPIError
2510
+
2508
2511
  req = ReviewRequest.model_validate(state["request"])
2509
2512
 
2510
2513
  # Step 0: check for prior review + dismiss commands (parallel)
@@ -2523,9 +2526,27 @@ async def _node_fetch_diff(state: ReviewState, config: RunnableConfig) -> dict[s
2523
2526
 
2524
2527
  pre_resolved_head_sha: str | None = config.get("configurable", {}).get("head_sha")
2525
2528
 
2526
- diff, description, head_sha, base_branch, scope_base_sha = await _fetch_pr_diff_and_description(
2527
- req, prior_sha=prior_sha, pre_resolved_head_sha=pre_resolved_head_sha
2528
- )
2529
+ def fetch(sha: str | None) -> Any:
2530
+ return _fetch_pr_diff_and_description(
2531
+ req, prior_sha=sha, pre_resolved_head_sha=pre_resolved_head_sha
2532
+ )
2533
+
2534
+ try:
2535
+ fetched = await fetch(prior_sha)
2536
+ except GitHubAPIError as exc:
2537
+ if prior is None or exc.status_code != 404:
2538
+ raise
2539
+ # Storage keys prior rounds by (repo, PR number), so a recreated repo or a rewritten
2540
+ # history can return a round whose commit is gone here. Review the whole PR instead.
2541
+ logger.warning(
2542
+ "Prior review %s sha %s is not reachable in %s (404); treating as round 1",
2543
+ prior.review_id,
2544
+ prior_sha,
2545
+ req.repo,
2546
+ )
2547
+ prior, prior_sha = None, None
2548
+ fetched = await fetch(None)
2549
+ diff, description, head_sha, base_branch, scope_base_sha = fetched
2529
2550
 
2530
2551
  # Log review metadata
2531
2552
  lines = diff.splitlines()
@@ -2550,6 +2571,11 @@ async def _node_fetch_diff(state: ReviewState, config: RunnableConfig) -> dict[s
2550
2571
  req, base_branch, head_sha, diff, prior_sha=prior_sha, base_sha=scope_base_sha
2551
2572
  )
2552
2573
 
2574
+ if prior_sha and full_changed_files and not unconfirmed_reason:
2575
+ # A catch-up merge puts the base branch's changes inside prior_sha..head. Keep only
2576
+ # files the PR itself changes, or the plan fans out over code nobody here wrote.
2577
+ diff = filter_diff_for_files(diff, [f.get("filename", "") for f in full_changed_files])
2578
+
2553
2579
  bench_config_changes: list[str] = []
2554
2580
  for f in full_changed_files:
2555
2581
  # Exclude files with status == 'removed' — pure deletion of a bench config is safe
@@ -0,0 +1,54 @@
1
+ """A prior review whose commit is not in this repo must not fail the round."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+ from unittest.mock import AsyncMock, MagicMock, patch
7
+
8
+ import pytest
9
+
10
+ from argus.github_client import GitHubAPIError
11
+ from argus.graph import _node_fetch_diff
12
+ from argus.models import ReviewRequest
13
+
14
+ _GH_CLIENT_CLASS = "argus.github_client.GitHubClient"
15
+
16
+
17
+ @pytest.mark.asyncio
18
+ async def test_unreachable_prior_sha_falls_back_to_round_one() -> None:
19
+ prior = MagicMock(reviewed_sha="a" * 40, findings=[], dismissed_findings=[])
20
+ fetch = AsyncMock(
21
+ side_effect=[
22
+ GitHubAPIError(404, "Not Found"),
23
+ ("diff", "desc", "b" * 40, "main", None),
24
+ ]
25
+ )
26
+ gh = MagicMock()
27
+ gh.get_compare_files.return_value = ([], False)
28
+ state = {"request": ReviewRequest(repo="org/repo", pr_number=4).model_dump()}
29
+
30
+ with (
31
+ patch("argus.graph._fetch_prior_review", new_callable=AsyncMock, return_value=prior),
32
+ patch("argus.graph._fetch_dismissed_findings", new_callable=AsyncMock, return_value=[]),
33
+ patch("argus.graph._fetch_pr_diff_and_description", fetch),
34
+ patch(_GH_CLIENT_CLASS, return_value=gh),
35
+ ):
36
+ result: dict[str, Any] = await _node_fetch_diff(state, {"configurable": {}})
37
+
38
+ assert [c.kwargs["prior_sha"] for c in fetch.call_args_list] == ["a" * 40, None]
39
+ assert result["prior_review"] == {}
40
+ assert result["diff"] == "diff"
41
+
42
+
43
+ @pytest.mark.asyncio
44
+ async def test_404_without_prior_still_raises() -> None:
45
+ fetch = AsyncMock(side_effect=GitHubAPIError(404, "Not Found"))
46
+ state = {"request": ReviewRequest(repo="org/repo", pr_number=4).model_dump()}
47
+
48
+ with (
49
+ patch("argus.graph._fetch_prior_review", new_callable=AsyncMock, return_value=None),
50
+ patch("argus.graph._fetch_dismissed_findings", new_callable=AsyncMock, return_value=[]),
51
+ patch("argus.graph._fetch_pr_diff_and_description", fetch),
52
+ pytest.raises(GitHubAPIError),
53
+ ):
54
+ await _node_fetch_diff(state, {"configurable": {}})
@@ -0,0 +1,57 @@
1
+ """Round 2+ reviews only the PR's own files, not what a catch-up merge brought from main."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+ from unittest.mock import AsyncMock, MagicMock, patch
7
+
8
+ import pytest
9
+
10
+ from argus.graph import _node_fetch_diff
11
+ from argus.models import ReviewRequest
12
+
13
+ _GH_CLIENT_CLASS = "argus.github_client.GitHubClient"
14
+
15
+
16
+ def _file_diff(path: str) -> str:
17
+ return f"diff --git a/{path} b/{path}\n--- a/{path}\n+++ b/{path}\n@@ -1 +1 @@\n-old\n+new\n"
18
+
19
+
20
+ def _prior() -> MagicMock:
21
+ prior = MagicMock(reviewed_sha="a" * 40, findings=[], dismissed_findings=[])
22
+ prior.model_dump.return_value = {"reviewed_sha": "a" * 40}
23
+ return prior
24
+
25
+
26
+ async def _run(compare_files: list[dict[str, Any]], truncated: bool = False) -> dict[str, Any]:
27
+ window = _file_diff("src/pr.py") + _file_diff("from_main/a.py") + _file_diff("from_main/b.py")
28
+ gh = MagicMock()
29
+ gh.get_compare_files.return_value = (compare_files, truncated)
30
+ state = {"request": ReviewRequest(repo="org/repo", pr_number=126).model_dump()}
31
+ with (
32
+ patch("argus.graph._fetch_prior_review", new_callable=AsyncMock, return_value=_prior()),
33
+ patch("argus.graph._fetch_dismissed_findings", new_callable=AsyncMock, return_value=[]),
34
+ patch(
35
+ "argus.graph._fetch_pr_diff_and_description",
36
+ new_callable=AsyncMock,
37
+ return_value=(window, "desc", "b" * 40, "main", "c" * 40),
38
+ ),
39
+ patch(_GH_CLIENT_CLASS, return_value=gh),
40
+ ):
41
+ return await _node_fetch_diff(state, {"configurable": {}})
42
+
43
+
44
+ @pytest.mark.asyncio
45
+ async def test_round2_diff_drops_files_the_pr_did_not_change() -> None:
46
+ result = await _run([{"filename": "src/pr.py", "status": "modified", "patch": "+new\n"}])
47
+
48
+ assert "src/pr.py" in result["diff"]
49
+ assert "from_main" not in result["diff"]
50
+
51
+
52
+ @pytest.mark.asyncio
53
+ async def test_round2_diff_is_kept_whole_when_pr_file_list_is_truncated() -> None:
54
+ files = [{"filename": "src/pr.py", "status": "modified", "patch": "+new\n"}]
55
+ result = await _run(files, truncated=True)
56
+
57
+ assert "from_main/a.py" in result["diff"]