Repository navigation
perf(review): batch nested failure evidence reads - #2278
Conversation
|
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
left a comment
There was a problem hiding this comment.
- CI failed: Upgrade release gate (failure).
- CI failed: tests (3.13, unit) (failure).
- CI failed: tests (3.14, unit) (failure).
- CI failed: tests (3.13, e2e) (failure).
- CI failed: tests (3.12, e2e) (failure).
- CI failed: tests (3.12, unit) (failure).
- CI failed: tests (3.11, unit) (failure).
- CI failed: tests (3.14, e2e) (failure).
- CI failed: tests (3.11, e2e) (failure).
- CI failed: upgrade-acceptance / Prepare upgrade artifacts and matrix (failure).
- Additional CI issues: PR checks.
AlexStocks
left a comment
There was a problem hiding this comment.
结论:无新增 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 即可。
57fc4d2 to
eb9a5e5
Compare
Which issue or RFC does this PR close?
Refs #2088.
Rationale for this change
_has_resolved_failure_evidenceloads each Artifact citation individually.Each
get()delegates to a single-referenceget_many(), repeating revisionand lineage queries for every citation.
Batching these reads reduces the SQL statements issued by a complete
experience.proposeoperation: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 eachmatching failure item. If batch validation raises
RepositoryError, readthe 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.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.