Skip to content

perf(review): batch nested failure evidence reads - #2278

Merged
hidb4ai merged 1 commit into
oceanbase:masterfrom
HaoooLee:perf/batch-failure-evidence
Oct 28, 2026
Merged

hidb4ai merged 1 commit into
oceanbase:masterfrom
HaoooLee:perf/batch-failure-evidence

Conversation

@HaoooLee

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

Refs #2088.

Rationale for this change

_has_resolved_failure_evidence loads each Artifact citation individually.
Each get() delegates to a single-reference get_many(), repeating revision
and lineage queries for every citation.

Batching these reads reduces the SQL statements issued by a complete
experience.propose operation:

Artifact citations Before After
4 13 7
32 69 7

Counts were measured at the SQLAlchemy engine level on in-memory SQLite.
Each measurement was repeated three times with identical results.

What changes are included in this PR?

Use the existing get_many() operation to read Artifact citations for each
matching failure item. If batch validation raises RepositoryError, read
the references in their original order to preserve the original error.

Add a complete-proposal SQL budget test, a focused scenario covering missing
references, historical revisions and early return, and three error-order
regressions. Reuse shared Task Outcome fixtures and correct the cue-matching
test with valid positive and negative controls.

Are there any user-facing changes?

Failure-evidence validation uses fewer database statements while preserving
proposal acceptance, error handling and stored candidate results.

How was this change tested?

  • uv run --locked prek run -a — all hooks passed, including Ruff and ty.
  • uv run --locked pytest tests/builtin/review/ -q — 33 passed.
  • Existing Source eligibility and failure-evidence rule tests — 10 passed.
  • git diff --check — passed.

The SQL budget test fails on the original implementation and passes with
this change, requiring equal counts for 4 and 32 citations within an
8-statement ceiling.

The three error-order tests reject a batch-only implementation and pass
with ordered fallback. The corrected cue-matching test also catches removal
of the matching check.

AI usage statement

OpenAI Codex assisted with implementation, test design and review.

@HaoooLee

Copy link
Copy Markdown
Contributor Author

I’m interested in PowerContext and would like to contribute more. Could you please review this PR when you have a chance? I’d appreciate any feedback or suggestions.

@hireview001 hireview001 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexStocks AlexStocks left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论:无新增 Finding;11 条红与本 PR 变更面无关

head 57fc4d25(2 文件:src/powercontext/builtin/review/service.py + tests/builtin/review/test_service.py)。

行为验证

  • pytest tests/builtin/review/test_service.py = 23 passed。
  • 变异反证:把 get_many + 逐条回退整体替换成原逐条 artifacts.get 后,同一文件 = 1 failed / 22 passed,失败为 test_failure_proposal_statement_count_does_not_grow_with_artifact_evidence(assert [14, 14, 14] == [70, 70, 70],即 4 条证据 14 条语句 vs 32 条证据 70 条语句)。该用例真实锁定"语句数不随证据数增长",_FAILURE_EVIDENCE_STATEMENT_CEILING = 8 在 head 上有效(small == large 且 max(large) <= 8)。
  • 回退分支不引入第二次全量读取:ArtifactRepository.get() 的非 for_update 路径本身就是 return (await self.get_many(connection, scope_id, (ref,)))[0],所以 except RepositoryError 里的逐条调用只用于还原原首个失败的错误优先级,不改变正常路径语句数。

11 条红 job 的归因

与本 PR 变更面无关:quality + tests (3.11|3.12|3.13|3.14, unit) 均为 upgrade_release_gate.GateError: Persistence changed (file set or content; CRLF/LF normalized)(test_repository_baseline_covers_all_three_databases),tests (*, e2e) 均为 test_owner_recovery_http.py::test_http_creation_and_restart_recover_the_original_owner → MigrationError: incompatible_schema。本 PR 不含 MANAGED_INPUTS 下任何文件;base 927bb6ee 的 managed_digest 实测 f0a1d364… 与 release/upgrade-support.json 声明的 9b67d639… 已不一致,修复来自 master 的 de435aa3/59572c6b(#2212),属基线滞后,rebase 到当前 master 即可。

@HaoooLee
HaoooLee force-pushed the perf/batch-failure-evidence branch from 57fc4d2 to eb9a5e5 Compare October 28, 2026 04:02

@hidb4ai hidb4ai left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hidb4ai
hidb4ai merged commit 2740493 into oceanbase:master Oct 28, 2026
71 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants